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()
{
	int i, N;
	long long A[301], xor = 0;
	scanf("%d", &N);
	for (i = 1; i <= N; i++) {
		scanf("%lld", &(A[i]));
		xor ^= A[i];
	}
	if (xor == 0) {
		printf("0\n");
		fflush(stdout);
		return 0;
	} else xor ^= A[1] ^ A[2];
	
	long long bit[41], x = A[1] + A[2], y = x - xor;
	for (i = 1, bit[0] = 1; i <= 40; i++) bit[i] = bit[i-1] << 1;
	if (y < 0 || x < y || y % 2 == 1 || y / 2 > A[1]) {
		printf("-1\n");
		fflush(stdout);
		return 0;
	} else y /= 2;
	
	int flag[41];
	long long a = y, b = y, c = y << 1;
	for (i = 0; i <= 40; i++) flag[i] = ((y & bit[i]) > 0)? 1: 0; 
	for (i = 0; i <= 40; i++) {
		if ((x & bit[i]) == (c & bit[i])) continue;
		else if (flag[i] == 1) break;
		flag[i] = -1;
		c += bit[i];
	}
	if (c != x) {
		printf("-1\n");
		fflush(stdout);
		return 0;
	}
	
	for (i = 40; i >= 0; i--) if (flag[i] == -1 && a + bit[i] <= A[1]) a += bit[i];
	if (a > 0) printf("%lld\n", A[1] - a);
	else printf("-1\n");
	fflush(stdout);
	return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%lld"
.LC2:
	.string	"0"
.LC3:
	.string	"-1"
.LC4:
	.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
	subq	$2992, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movq	$0, -2976(%rbp)
	leaq	-2984(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$1, -2980(%rbp)
	jmp	.L2
.L3:
	leaq	-2416(%rbp), %rdx
	movl	-2980(%rbp), %eax
	cltq
	salq	$3, %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-2980(%rbp), %eax
	cltq
	movq	-2416(%rbp,%rax,8), %rax
	xorq	%rax, -2976(%rbp)
	addl	$1, -2980(%rbp)
.L2:
	movl	-2984(%rbp), %eax
	cmpl	%eax, -2980(%rbp)
	jle	.L3
	cmpq	$0, -2976(%rbp)
	jne	.L4
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	movq	stdout(%rip), %rax
	movq	%rax, %rdi
	call	fflush@PLT
	movl	$0, %eax
	jmp	.L24
.L4:
	movq	-2408(%rbp), %rdx
	movq	-2400(%rbp), %rax
	xorq	%rdx, %rax
	xorq	%rax, -2976(%rbp)
	movq	-2408(%rbp), %rdx
	movq	-2400(%rbp), %rax
	addq	%rdx, %rax
	movq	%rax, -2952(%rbp)
	movq	-2952(%rbp), %rax
	subq	-2976(%rbp), %rax
	movq	%rax, -2944(%rbp)
	movl	$1, -2980(%rbp)
	movq	$1, -2752(%rbp)
	jmp	.L6
.L7:
	movl	-2980(%rbp), %eax
	subl	$1, %eax
	cltq
	movq	-2752(%rbp,%rax,8), %rax
	leaq	(%rax,%rax), %rdx
	movl	-2980(%rbp), %eax
	cltq
	movq	%rdx, -2752(%rbp,%rax,8)
	addl	$1, -2980(%rbp)
.L6:
	cmpl	$40, -2980(%rbp)
	jle	.L7
	cmpq	$0, -2944(%rbp)
	js	.L8
	movq	-2952(%rbp), %rax
	cmpq	-2944(%rbp), %rax
	jl	.L8
	movq	-2944(%rbp), %rax
	cqto
	shrq	$63, %rdx
	addq	%rdx, %rax
	andl	$1, %eax
	subq	%rdx, %rax
	cmpq	$1, %rax
	je	.L8
	movq	-2944(%rbp), %rax
	movq	%rax, %rdx
	shrq	$63, %rdx
	addq	%rdx, %rax
	sarq	%rax
	movq	%rax, %rdx
	movq	-2408(%rbp), %rax
	cmpq	%rax, %rdx
	jle	.L9
.L8:
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	movq	stdout(%rip), %rax
	movq	%rax, %rdi
	call	fflush@PLT
	movl	$0, %eax
	jmp	.L24
.L9:
	movq	-2944(%rbp), %rax
	movq	%rax, %rdx
	shrq	$63, %rdx
	addq	%rdx, %rax
	sarq	%rax
	movq	%rax, -2944(%rbp)
	movq	-2944(%rbp), %rax
	movq	%rax, -2968(%rbp)
	movq	-2944(%rbp), %rax
	movq	%rax, -2936(%rbp)
	movq	-2944(%rbp), %rax
	addq	%rax, %rax
	movq	%rax, -2960(%rbp)
	movl	$0, -2980(%rbp)
	jmp	.L10
.L11:
	movl	-2980(%rbp), %eax
	cltq
	movq	-2752(%rbp,%rax,8), %rax
	andq	-2944(%rbp), %rax
	testq	%rax, %rax
	setg	%al
	movzbl	%al, %edx
	movl	-2980(%rbp), %eax
	cltq
	movl	%edx, -2928(%rbp,%rax,4)
	addl	$1, -2980(%rbp)
.L10:
	cmpl	$40, -2980(%rbp)
	jle	.L11
	movl	$0, -2980(%rbp)
	jmp	.L12
.L17:
	movq	-2952(%rbp), %rax
	xorq	-2960(%rbp), %rax
	movq	%rax, %rdx
	movl	-2980(%rbp), %eax
	cltq
	movq	-2752(%rbp,%rax,8), %rax
	andq	%rdx, %rax
	testq	%rax, %rax
	je	.L26
	movl	-2980(%rbp), %eax
	cltq
	movl	-2928(%rbp,%rax,4), %eax
	cmpl	$1, %eax
	je	.L27
	movl	-2980(%rbp), %eax
	cltq
	movl	$-1, -2928(%rbp,%rax,4)
	movl	-2980(%rbp), %eax
	cltq
	movq	-2752(%rbp,%rax,8), %rax
	addq	%rax, -2960(%rbp)
	jmp	.L14
.L26:
	nop
.L14:
	addl	$1, -2980(%rbp)
.L12:
	cmpl	$40, -2980(%rbp)
	jle	.L17
	jmp	.L16
.L27:
	nop
.L16:
	movq	-2960(%rbp), %rax
	cmpq	-2952(%rbp), %rax
	je	.L18
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	movq	stdout(%rip), %rax
	movq	%rax, %rdi
	call	fflush@PLT
	movl	$0, %eax
	jmp	.L24
.L18:
	movl	$40, -2980(%rbp)
	jmp	.L19
.L21:
	movl	-2980(%rbp), %eax
	cltq
	movl	-2928(%rbp,%rax,4), %eax
	cmpl	$-1, %eax
	jne	.L20
	movl	-2980(%rbp), %eax
	cltq
	movq	-2752(%rbp,%rax,8), %rdx
	movq	-2968(%rbp), %rax
	addq	%rax, %rdx
	movq	-2408(%rbp), %rax
	cmpq	%rax, %rdx
	jg	.L20
	movl	-2980(%rbp), %eax
	cltq
	movq	-2752(%rbp,%rax,8), %rax
	addq	%rax, -2968(%rbp)
.L20:
	subl	$1, -2980(%rbp)
.L19:
	cmpl	$0, -2980(%rbp)
	jns	.L21
	cmpq	$0, -2968(%rbp)
	jle	.L22
	movq	-2408(%rbp), %rax
	subq	-2968(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC4(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L23
.L22:
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
.L23:
	movq	stdout(%rip), %rax
	movq	%rax, %rdi
	call	fflush@PLT
	movl	$0, %eax
.L24:
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L25
	call	__stack_chk_fail@PLT
.L25:
	leave
	.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	"%d"
.LC1:
	.string	"%lld"
.LC2:
	.string	"0"
.LC3:
	.string	"-1"
.LC4:
	.string	"%lld\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
	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	$2952, %rsp
	.cfi_def_cfa_offset 2992
	movq	%fs:40, %rax
	movq	%rax, 2936(%rsp)
	xorl	%eax, %eax
	leaq	12(%rsp), %rsi
	call	__isoc99_scanf@PLT
	movl	12(%rsp), %eax
	testl	%eax, %eax
	jle	.L2
	movl	$1, %ebx
	xorl	%ebp, %ebp
	leaq	528(%rsp), %r12
	leaq	.LC1(%rip), %r13
	.p2align 4,,10
	.p2align 3
.L3:
	leaq	(%r12,%rbx,8), %rsi
	movq	%r13, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movq	(%r12,%rbx,8), %rax
	movq	%rbp, %rdx
	addq	$1, %rbx
	xorq	%rax, %rbp
	cmpl	%ebx, 12(%rsp)
	jge	.L3
	cmpq	%rdx, %rax
	je	.L2
	movq	536(%rsp), %rdx
	movq	544(%rsp), %rax
	movq	$1, 192(%rsp)
	leaq	192(%rsp), %r10
	movq	%r10, %r9
	leaq	520(%rsp), %rsi
	movl	$1, %ecx
	leaq	(%rdx,%rax), %r11
	xorq	%rdx, %rax
	xorq	%rbp, %rax
	movq	%r11, %rbx
	subq	%rax, %rbx
	leaq	200(%rsp), %rax
	.p2align 4,,10
	.p2align 3
.L6:
	addq	%rcx, %rcx
	addq	$8, %rax
	movq	%rcx, -8(%rax)
	cmpq	%rsi, %rax
	jne	.L6
	testq	%rbx, %rbx
	js	.L15
	cmpq	%rbx, %r11
	jl	.L15
	testb	$1, %bl
	jne	.L15
	movq	%rbx, %rdi
	sarq	%rdi
	cmpq	%rdi, %rdx
	jl	.L15
	andq	$-2, %rbx
	xorl	%eax, %eax
	leaq	16(%rsp), %r8
	.p2align 4,,10
	.p2align 3
.L9:
	movq	%rdi, %rcx
	andq	(%r10,%rax,8), %rcx
	setg	%cl
	movzbl	%cl, %ecx
	movl	%ecx, (%r8,%rax,4)
	addq	$1, %rax
	cmpq	$41, %rax
	jne	.L9
	movq	%r8, %rax
	jmp	.L12
	.p2align 4,,10
	.p2align 3
.L31:
	movl	$-1, (%rax)
	addq	%rcx, %rbx
.L10:
	addq	$8, %r9
	addq	$4, %rax
	cmpq	%rsi, %r9
	je	.L11
.L12:
	movq	%r11, %rbp
	movq	(%r9), %rcx
	xorq	%rbx, %rbp
	testq	%rcx, %rbp
	je	.L10
	cmpl	$1, (%rax)
	jne	.L31
.L11:
	movl	$40, %eax
	cmpq	%r11, %rbx
	jne	.L15
	.p2align 4,,10
	.p2align 3
.L13:
	cmpl	$-1, (%r8,%rax,4)
	jne	.L14
	movq	(%r10,%rax,8), %rcx
	addq	%rdi, %rcx
	cmpq	%rcx, %rdx
	cmovge	%rcx, %rdi
.L14:
	subq	$1, %rax
	jnb	.L13
	testq	%rdi, %rdi
	jle	.L15
	subq	%rdi, %rdx
	leaq	.LC4(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L16
.L15:
	leaq	.LC3(%rip), %rdi
	call	puts@PLT
.L16:
	movq	stdout(%rip), %rdi
	call	fflush@PLT
.L5:
	movq	2936(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L32
	addq	$2952, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 40
	xorl	%eax, %eax
	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
.L2:
	.cfi_restore_state
	leaq	.LC2(%rip), %rdi
	call	puts@PLT
	movq	stdout(%rip), %rdi
	call	fflush@PLT
	jmp	.L5
.L32:
	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	"%d"
.LC1:
	.string	"%lld"
.LC2:
	.string	"0"
.LC3:
	.string	"-1"
.LC4:
	.string	"%lld\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
	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	$2952, %rsp
	.cfi_def_cfa_offset 2992
	movq	%fs:40, %rax
	movq	%rax, 2936(%rsp)
	xorl	%eax, %eax
	leaq	12(%rsp), %rsi
	call	__isoc99_scanf@PLT
	movl	12(%rsp), %eax
	testl	%eax, %eax
	jle	.L2
	movl	$1, %ebx
	xorl	%ebp, %ebp
	leaq	528(%rsp), %r12
	leaq	.LC1(%rip), %r13
	.p2align 4,,10
	.p2align 3
.L3:
	leaq	(%r12,%rbx,8), %rsi
	movq	%r13, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movq	(%r12,%rbx,8), %rax
	movq	%rbp, %rdx
	addq	$1, %rbx
	xorq	%rax, %rbp
	cmpl	%ebx, 12(%rsp)
	jge	.L3
	cmpq	%rdx, %rax
	je	.L2
	movq	536(%rsp), %rdx
	movq	544(%rsp), %rax
	movq	$1, 192(%rsp)
	leaq	192(%rsp), %r10
	movq	%r10, %r9
	leaq	520(%rsp), %rsi
	movl	$1, %ecx
	leaq	(%rdx,%rax), %r11
	xorq	%rdx, %rax
	xorq	%rbp, %rax
	movq	%r11, %rbx
	subq	%rax, %rbx
	leaq	200(%rsp), %rax
	.p2align 4,,10
	.p2align 3
.L6:
	addq	%rcx, %rcx
	addq	$8, %rax
	movq	%rcx, -8(%rax)
	cmpq	%rsi, %rax
	jne	.L6
	testq	%rbx, %rbx
	js	.L15
	cmpq	%rbx, %r11
	jl	.L15
	testb	$1, %bl
	jne	.L15
	movq	%rbx, %rdi
	sarq	%rdi
	cmpq	%rdi, %rdx
	jl	.L15
	andq	$-2, %rbx
	xorl	%eax, %eax
	leaq	16(%rsp), %r8
	.p2align 4,,10
	.p2align 3
.L9:
	movq	%rdi, %rcx
	andq	(%r10,%rax,8), %rcx
	setg	%cl
	movzbl	%cl, %ecx
	movl	%ecx, (%r8,%rax,4)
	addq	$1, %rax
	cmpq	$41, %rax
	jne	.L9
	movq	%r8, %rax
	jmp	.L12
	.p2align 4,,10
	.p2align 3
.L31:
	movl	$-1, (%rax)
	addq	%rcx, %rbx
.L10:
	addq	$8, %r9
	addq	$4, %rax
	cmpq	%rsi, %r9
	je	.L11
.L12:
	movq	%r11, %rbp
	movq	(%r9), %rcx
	xorq	%rbx, %rbp
	testq	%rcx, %rbp
	je	.L10
	cmpl	$1, (%rax)
	jne	.L31
.L11:
	movl	$40, %eax
	cmpq	%r11, %rbx
	jne	.L15
	.p2align 4,,10
	.p2align 3
.L13:
	cmpl	$-1, (%r8,%rax,4)
	jne	.L14
	movq	(%r10,%rax,8), %rcx
	addq	%rdi, %rcx
	cmpq	%rcx, %rdx
	cmovge	%rcx, %rdi
.L14:
	subq	$1, %rax
	jnb	.L13
	testq	%rdi, %rdi
	jle	.L15
	subq	%rdi, %rdx
	leaq	.LC4(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L16
.L15:
	leaq	.LC3(%rip), %rdi
	call	puts@PLT
.L16:
	movq	stdout(%rip), %rdi
	call	fflush@PLT
.L5:
	movq	2936(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L32
	addq	$2952, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 40
	xorl	%eax, %eax
	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
.L2:
	.cfi_restore_state
	leaq	.LC2(%rip), %rdi
	call	puts@PLT
	movq	stdout(%rip), %rdi
	call	fflush@PLT
	jmp	.L5
.L32:
	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()
{
	int i, N;
	long long A[301], xor = 0;
	scanf("%d", &N);
	for (i = 1; i <= N; i++) {
		scanf("%lld", &(A[i]));
		xor ^= A[i];
	}
	if (xor == 0) {
		printf("0\n");
		fflush(stdout);
		return 0;
	} else xor ^= A[1] ^ A[2];
	
	long long bit[41], x = A[1] + A[2], y = x - xor;
	for (i = 1, bit[0] = 1; i <= 40; i++) bit[i] = bit[i-1] << 1;
	if (y < 0 || x < y || y % 2 == 1 || y / 2 > A[1]) {
		printf("-1\n");
		fflush(stdout);
		return 0;
	} else y /= 2;
	
	int flag[41];
	long long a = y, b = y, c = y << 1;
	for (i = 0; i <= 40; i++) flag[i] = ((y & bit[i]) > 0)? 1: 0; 
	for (i = 0; i <= 40; i++) {
		if ((x & bit[i]) == (c & bit[i])) continue;
		else if (flag[i] == 1) break;
		flag[i] = -1;
		c += bit[i];
	}
	if (c != x) {
		printf("-1\n");
		fflush(stdout);
		return 0;
	}
	
	for (i = 40; i >= 0; i--) if (flag[i] == -1 && a + bit[i] <= A[1]) a += bit[i];
	if (a > 0) printf("%lld\n", A[1] - a);
	else printf("-1\n");
	fflush(stdout);
	return 0;
}
2
3 6
 2
5 5
 2
7 5
 8
10 9 8 8 6 9 7 3
 2
5 1
 2
11 1
 2
21 1
 2
19 1
 2
7 -1
 3
869 1 534

-1
 0
 1
 3
 2
 5
 10
 9
 4
 167

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()
{
	int i, N;
	long long A[301], xor = 0;
	scanf("%d", &N);
	for (i = 1; i <= N; i++) {
		scanf("%lld", &(A[i]));
		xor ^= A[i];
	}
	if (xor == 0) {
		printf("0\n");
		fflush(stdout);
		return 0;
	} else xor ^= A[1] ^ A[2];
	
	long long bit[41], x = A[1] + A[2], y = x - xor;
	for (i = 1, bit[0] = 1; i <= 40; i++) bit[i] = bit[i-1] << 1;
	if (y < 0 || x < y || y % 2 == 1 || y / 2 > A[1]) {
		printf("-1\n");
		fflush(stdout);
		return 0;
	} else y /= 2;
	
	int flag[41];
	long long a = y, b = y, c = y << 1;
	for (i = 0; i <= 40; i++) flag[i] = ((y & bit[i]) > 0)? 1: 0; 
	for (i = 0; i <= 40; i++) {
		if ((x & bit[i]) == (c & bit[i])) continue;
		else if (flag[i] == 1) break;
		flag[i] = -1;
		c += bit[i];
	}
	if (c != x) {
		printf("-1\n");
		fflush(stdout);
		return 0;
	}
	
	for (i = 40; i >= 0; i--) if (flag[i] == -1 && a + bit[i] <= A[1]) a += bit[i];
	if (a > 0) printf("%lld\n", A[1] - a);
	else printf("-1\n");
	fflush(stdout);
	return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%lld"
.LC2:
	.string	"0"
.LC3:
	.string	"-1"
.LC4:
	.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
	subq	$2992, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movq	$0, -2976(%rbp)
	leaq	-2984(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$1, -2980(%rbp)
	jmp	.L2
.L3:
	leaq	-2416(%rbp), %rdx
	movl	-2980(%rbp), %eax
	cltq
	salq	$3, %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-2980(%rbp), %eax
	cltq
	movq	-2416(%rbp,%rax,8), %rax
	xorq	%rax, -2976(%rbp)
	addl	$1, -2980(%rbp)
.L2:
	movl	-2984(%rbp), %eax
	cmpl	%eax, -2980(%rbp)
	jle	.L3
	cmpq	$0, -2976(%rbp)
	jne	.L4
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	movq	stdout(%rip), %rax
	movq	%rax, %rdi
	call	fflush@PLT
	movl	$0, %eax
	jmp	.L24
.L4:
	movq	-2408(%rbp), %rdx
	movq	-2400(%rbp), %rax
	xorq	%rdx, %rax
	xorq	%rax, -2976(%rbp)
	movq	-2408(%rbp), %rdx
	movq	-2400(%rbp), %rax
	addq	%rdx, %rax
	movq	%rax, -2952(%rbp)
	movq	-2952(%rbp), %rax
	subq	-2976(%rbp), %rax
	movq	%rax, -2944(%rbp)
	movl	$1, -2980(%rbp)
	movq	$1, -2752(%rbp)
	jmp	.L6
.L7:
	movl	-2980(%rbp), %eax
	subl	$1, %eax
	cltq
	movq	-2752(%rbp,%rax,8), %rax
	leaq	(%rax,%rax), %rdx
	movl	-2980(%rbp), %eax
	cltq
	movq	%rdx, -2752(%rbp,%rax,8)
	addl	$1, -2980(%rbp)
.L6:
	cmpl	$40, -2980(%rbp)
	jle	.L7
	cmpq	$0, -2944(%rbp)
	js	.L8
	movq	-2952(%rbp), %rax
	cmpq	-2944(%rbp), %rax
	jl	.L8
	movq	-2944(%rbp), %rax
	cqto
	shrq	$63, %rdx
	addq	%rdx, %rax
	andl	$1, %eax
	subq	%rdx, %rax
	cmpq	$1, %rax
	je	.L8
	movq	-2944(%rbp), %rax
	movq	%rax, %rdx
	shrq	$63, %rdx
	addq	%rdx, %rax
	sarq	%rax
	movq	%rax, %rdx
	movq	-2408(%rbp), %rax
	cmpq	%rax, %rdx
	jle	.L9
.L8:
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	movq	stdout(%rip), %rax
	movq	%rax, %rdi
	call	fflush@PLT
	movl	$0, %eax
	jmp	.L24
.L9:
	movq	-2944(%rbp), %rax
	movq	%rax, %rdx
	shrq	$63, %rdx
	addq	%rdx, %rax
	sarq	%rax
	movq	%rax, -2944(%rbp)
	movq	-2944(%rbp), %rax
	movq	%rax, -2968(%rbp)
	movq	-2944(%rbp), %rax
	movq	%rax, -2936(%rbp)
	movq	-2944(%rbp), %rax
	addq	%rax, %rax
	movq	%rax, -2960(%rbp)
	movl	$0, -2980(%rbp)
	jmp	.L10
.L11:
	movl	-2980(%rbp), %eax
	cltq
	movq	-2752(%rbp,%rax,8), %rax
	andq	-2944(%rbp), %rax
	testq	%rax, %rax
	setg	%al
	movzbl	%al, %edx
	movl	-2980(%rbp), %eax
	cltq
	movl	%edx, -2928(%rbp,%rax,4)
	addl	$1, -2980(%rbp)
.L10:
	cmpl	$40, -2980(%rbp)
	jle	.L11
	movl	$0, -2980(%rbp)
	jmp	.L12
.L17:
	movq	-2952(%rbp), %rax
	xorq	-2960(%rbp), %rax
	movq	%rax, %rdx
	movl	-2980(%rbp), %eax
	cltq
	movq	-2752(%rbp,%rax,8), %rax
	andq	%rdx, %rax
	testq	%rax, %rax
	je	.L26
	movl	-2980(%rbp), %eax
	cltq
	movl	-2928(%rbp,%rax,4), %eax
	cmpl	$1, %eax
	je	.L27
	movl	-2980(%rbp), %eax
	cltq
	movl	$-1, -2928(%rbp,%rax,4)
	movl	-2980(%rbp), %eax
	cltq
	movq	-2752(%rbp,%rax,8), %rax
	addq	%rax, -2960(%rbp)
	jmp	.L14
.L26:
	nop
.L14:
	addl	$1, -2980(%rbp)
.L12:
	cmpl	$40, -2980(%rbp)
	jle	.L17
	jmp	.L16
.L27:
	nop
.L16:
	movq	-2960(%rbp), %rax
	cmpq	-2952(%rbp), %rax
	je	.L18
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	movq	stdout(%rip), %rax
	movq	%rax, %rdi
	call	fflush@PLT
	movl	$0, %eax
	jmp	.L24
.L18:
	movl	$40, -2980(%rbp)
	jmp	.L19
.L21:
	movl	-2980(%rbp), %eax
	cltq
	movl	-2928(%rbp,%rax,4), %eax
	cmpl	$-1, %eax
	jne	.L20
	movl	-2980(%rbp), %eax
	cltq
	movq	-2752(%rbp,%rax,8), %rdx
	movq	-2968(%rbp), %rax
	addq	%rax, %rdx
	movq	-2408(%rbp), %rax
	cmpq	%rax, %rdx
	jg	.L20
	movl	-2980(%rbp), %eax
	cltq
	movq	-2752(%rbp,%rax,8), %rax
	addq	%rax, -2968(%rbp)
.L20:
	subl	$1, -2980(%rbp)
.L19:
	cmpl	$0, -2980(%rbp)
	jns	.L21
	cmpq	$0, -2968(%rbp)
	jle	.L22
	movq	-2408(%rbp), %rax
	subq	-2968(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC4(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L23
.L22:
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
.L23:
	movq	stdout(%rip), %rax
	movq	%rax, %rdi
	call	fflush@PLT
	movl	$0, %eax
.L24:
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L25
	call	__stack_chk_fail@PLT
.L25:
	leave
	.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.
train
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%lld"
.LC2:
	.string	"0"
.LC3:
	.string	"-1"
.LC4:
	.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
	subq	$2992, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movq	$0, -2976(%rbp)
	leaq	-2984(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$1, -2980(%rbp)
	jmp	.L2
.L3:
	leaq	-2416(%rbp), %rdx
	movl	-2980(%rbp), %eax
	cltq
	salq	$3, %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-2980(%rbp), %eax
	cltq
	movq	-2416(%rbp,%rax,8), %rax
	xorq	%rax, -2976(%rbp)
	addl	$1, -2980(%rbp)
.L2:
	movl	-2984(%rbp), %eax
	cmpl	%eax, -2980(%rbp)
	jle	.L3
	cmpq	$0, -2976(%rbp)
	jne	.L4
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	movq	stdout(%rip), %rax
	movq	%rax, %rdi
	call	fflush@PLT
	movl	$0, %eax
	jmp	.L24
.L4:
	movq	-2408(%rbp), %rdx
	movq	-2400(%rbp), %rax
	xorq	%rdx, %rax
	xorq	%rax, -2976(%rbp)
	movq	-2408(%rbp), %rdx
	movq	-2400(%rbp), %rax
	addq	%rdx, %rax
	movq	%rax, -2952(%rbp)
	movq	-2952(%rbp), %rax
	subq	-2976(%rbp), %rax
	movq	%rax, -2944(%rbp)
	movl	$1, -2980(%rbp)
	movq	$1, -2752(%rbp)
	jmp	.L6
.L7:
	movl	-2980(%rbp), %eax
	subl	$1, %eax
	cltq
	movq	-2752(%rbp,%rax,8), %rax
	leaq	(%rax,%rax), %rdx
	movl	-2980(%rbp), %eax
	cltq
	movq	%rdx, -2752(%rbp,%rax,8)
	addl	$1, -2980(%rbp)
.L6:
	cmpl	$40, -2980(%rbp)
	jle	.L7
	cmpq	$0, -2944(%rbp)
	js	.L8
	movq	-2952(%rbp), %rax
	cmpq	-2944(%rbp), %rax
	jl	.L8
	movq	-2944(%rbp), %rax
	cqto
	shrq	$63, %rdx
	addq	%rdx, %rax
	andl	$1, %eax
	subq	%rdx, %rax
	cmpq	$1, %rax
	je	.L8
	movq	-2944(%rbp), %rax
	movq	%rax, %rdx
	shrq	$63, %rdx
	addq	%rdx, %rax
	sarq	%rax
	movq	%rax, %rdx
	movq	-2408(%rbp), %rax
	cmpq	%rax, %rdx
	jle	.L9
.L8:
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	movq	stdout(%rip), %rax
	movq	%rax, %rdi
	call	fflush@PLT
	movl	$0, %eax
	jmp	.L24
.L9:
	movq	-2944(%rbp), %rax
	movq	%rax, %rdx
	shrq	$63, %rdx
	addq	%rdx, %rax
	sarq	%rax
	movq	%rax, -2944(%rbp)
	movq	-2944(%rbp), %rax
	movq	%rax, -2968(%rbp)
	movq	-2944(%rbp), %rax
	movq	%rax, -2936(%rbp)
	movq	-2944(%rbp), %rax
	addq	%rax, %rax
	movq	%rax, -2960(%rbp)
	movl	$0, -2980(%rbp)
	jmp	.L10
.L11:
	movl	-2980(%rbp), %eax
	cltq
	movq	-2752(%rbp,%rax,8), %rax
	andq	-2944(%rbp), %rax
	testq	%rax, %rax
	setg	%al
	movzbl	%al, %edx
	movl	-2980(%rbp), %eax
	cltq
	movl	%edx, -2928(%rbp,%rax,4)
	addl	$1, -2980(%rbp)
.L10:
	cmpl	$40, -2980(%rbp)
	jle	.L11
	movl	$0, -2980(%rbp)
	jmp	.L12
.L17:
	movq	-2952(%rbp), %rax
	xorq	-2960(%rbp), %rax
	movq	%rax, %rdx
	movl	-2980(%rbp), %eax
	cltq
	movq	-2752(%rbp,%rax,8), %rax
	andq	%rdx, %rax
	testq	%rax, %rax
	je	.L26
	movl	-2980(%rbp), %eax
	cltq
	movl	-2928(%rbp,%rax,4), %eax
	cmpl	$1, %eax
	je	.L27
	movl	-2980(%rbp), %eax
	cltq
	movl	$-1, -2928(%rbp,%rax,4)
	movl	-2980(%rbp), %eax
	cltq
	movq	-2752(%rbp,%rax,8), %rax
	addq	%rax, -2960(%rbp)
	jmp	.L14
.L26:
	nop
.L14:
	addl	$1, -2980(%rbp)
.L12:
	cmpl	$40, -2980(%rbp)
	jle	.L17
	jmp	.L16
.L27:
	nop
.L16:
	movq	-2960(%rbp), %rax
	cmpq	-2952(%rbp), %rax
	je	.L18
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	movq	stdout(%rip), %rax
	movq	%rax, %rdi
	call	fflush@PLT
	movl	$0, %eax
	jmp	.L24
.L18:
	movl	$40, -2980(%rbp)
	jmp	.L19
.L21:
	movl	-2980(%rbp), %eax
	cltq
	movl	-2928(%rbp,%rax,4), %eax
	cmpl	$-1, %eax
	jne	.L20
	movl	-2980(%rbp), %eax
	cltq
	movq	-2752(%rbp,%rax,8), %rdx
	movq	-2968(%rbp), %rax
	addq	%rax, %rdx
	movq	-2408(%rbp), %rax
	cmpq	%rax, %rdx
	jg	.L20
	movl	-2980(%rbp), %eax
	cltq
	movq	-2752(%rbp,%rax,8), %rax
	addq	%rax, -2968(%rbp)
.L20:
	subl	$1, -2980(%rbp)
.L19:
	cmpl	$0, -2980(%rbp)
	jns	.L21
	cmpq	$0, -2968(%rbp)
	jle	.L22
	movq	-2408(%rbp), %rax
	subq	-2968(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC4(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L23
.L22:
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
.L23:
	movq	stdout(%rip), %rax
	movq	%rax, %rdi
	call	fflush@PLT
	movl	$0, %eax
.L24:
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L25
	call	__stack_chk_fail@PLT
.L25:
	leave
	.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:
