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>
#include <stdlib.h>

int main()
{
	long long N;
	scanf("%lld", &N);

	int i, digit[64] = {};
	long long n, l, u;
	while (N != 0) {
		for (i = 0, n = 1, l = 0, u = 1; N < l || u < N; i++) {
			n *= -2;
			if (i % 2 == 0) l += n;
			else u += n;
		}
		N -= n;
		digit[i] = 1;
	}

	for (i = 63; i > 0 && digit[i] == 0; i--);
	for (; i >= 0; i--) printf("%d", digit[i]);
	fflush(stdout);
	return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%lld"
.LC1:
	.string	"%d"
	.text
	.globl	main
	.type	main, @function
main:
.LFB6:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$320, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-304(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	leaq	-272(%rbp), %rdx
	movl	$0, %eax
	movl	$32, %ecx
	movq	%rdx, %rdi
	rep stosq
	jmp	.L2
.L7:
	movl	$0, -308(%rbp)
	movq	$1, -296(%rbp)
	movq	$0, -288(%rbp)
	movq	$1, -280(%rbp)
	jmp	.L3
.L6:
	movq	-296(%rbp), %rdx
	movl	$0, %eax
	subq	%rdx, %rax
	addq	%rax, %rax
	movq	%rax, -296(%rbp)
	movl	-308(%rbp), %eax
	andl	$1, %eax
	testl	%eax, %eax
	jne	.L4
	movq	-296(%rbp), %rax
	addq	%rax, -288(%rbp)
	jmp	.L5
.L4:
	movq	-296(%rbp), %rax
	addq	%rax, -280(%rbp)
.L5:
	addl	$1, -308(%rbp)
.L3:
	movq	-304(%rbp), %rax
	cmpq	%rax, -288(%rbp)
	jg	.L6
	movq	-304(%rbp), %rax
	cmpq	%rax, -280(%rbp)
	jl	.L6
	movq	-304(%rbp), %rax
	subq	-296(%rbp), %rax
	movq	%rax, -304(%rbp)
	movl	-308(%rbp), %eax
	cltq
	movl	$1, -272(%rbp,%rax,4)
.L2:
	movq	-304(%rbp), %rax
	testq	%rax, %rax
	jne	.L7
	movl	$63, -308(%rbp)
	jmp	.L8
.L10:
	subl	$1, -308(%rbp)
.L8:
	cmpl	$0, -308(%rbp)
	jle	.L11
	movl	-308(%rbp), %eax
	cltq
	movl	-272(%rbp,%rax,4), %eax
	testl	%eax, %eax
	je	.L10
	jmp	.L11
.L12:
	movl	-308(%rbp), %eax
	cltq
	movl	-272(%rbp,%rax,4), %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	subl	$1, -308(%rbp)
.L11:
	cmpl	$0, -308(%rbp)
	jns	.L12
	movq	stdout(%rip), %rax
	movq	%rax, %rdi
	call	fflush@PLT
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L14
	call	__stack_chk_fail@PLT
.L14:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.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	"%d"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB39:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	leaq	.LC0(%rip), %rdi
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	subq	$288, %rsp
	.cfi_def_cfa_offset 320
	movq	%fs:40, %rax
	movq	%rax, 280(%rsp)
	xorl	%eax, %eax
	leaq	8(%rsp), %rsi
	leaq	16(%rsp), %rbx
	call	__isoc99_scanf@PLT
	movq	8(%rsp), %rsi
	xorl	%eax, %eax
	movq	%rbx, %rdi
	movl	$32, %ecx
	rep stosq
	testq	%rsi, %rsi
	je	.L3
	.p2align 4,,10
	.p2align 3
.L2:
	movl	$1, %eax
	xorl	%edx, %edx
	cmpq	$1, %rsi
	je	.L8
	movl	$1, %edi
	xorl	%ecx, %ecx
	movl	$1, %eax
	xorl	%edx, %edx
	.p2align 4,,10
	.p2align 3
.L18:
	negq	%rax
	addq	%rax, %rax
	testb	$1, %dl
	jne	.L4
	addq	%rax, %rcx
.L5:
	addl	$1, %edx
	cmpq	%rcx, %rsi
	jl	.L18
	cmpq	%rdi, %rsi
	jg	.L18
.L8:
	movslq	%edx, %rdx
	movl	$1, 16(%rsp,%rdx,4)
	subq	%rax, %rsi
	jne	.L2
	movq	$0, 8(%rsp)
.L3:
	movl	$63, %eax
	jmp	.L9
	.p2align 4,,10
	.p2align 3
.L11:
	subq	$1, %rax
	je	.L10
.L9:
	movl	(%rbx,%rax,4), %ecx
	movslq	%eax, %rdx
	testl	%ecx, %ecx
	je	.L11
	salq	$2, %rdx
	salq	$2, %rax
	leaq	.LC1(%rip), %r12
	leaq	12(%rsp,%rdx), %rbp
	addq	%rdx, %rbx
	subq	%rax, %rbp
	.p2align 4,,10
	.p2align 3
.L12:
	movl	(%rbx), %edx
	movq	%r12, %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	subq	$4, %rbx
	call	__printf_chk@PLT
	cmpq	%rbx, %rbp
	jne	.L12
.L13:
	movq	stdout(%rip), %rdi
	call	fflush@PLT
	movq	280(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L22
	addq	$288, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 32
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L4:
	.cfi_restore_state
	addq	%rax, %rdi
	jmp	.L5
.L10:
	movl	16(%rsp), %edx
	leaq	.LC1(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L13
.L22:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE39:
	.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	"%d"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB39:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	leaq	.LC0(%rip), %rdi
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	subq	$288, %rsp
	.cfi_def_cfa_offset 320
	movq	%fs:40, %rax
	movq	%rax, 280(%rsp)
	xorl	%eax, %eax
	leaq	8(%rsp), %rsi
	leaq	16(%rsp), %rbx
	call	__isoc99_scanf@PLT
	movq	8(%rsp), %rsi
	xorl	%eax, %eax
	movq	%rbx, %rdi
	movl	$32, %ecx
	rep stosq
	testq	%rsi, %rsi
	je	.L3
	.p2align 4,,10
	.p2align 3
.L2:
	movl	$1, %eax
	xorl	%edx, %edx
	cmpq	$1, %rsi
	je	.L8
	movl	$1, %edi
	xorl	%ecx, %ecx
	movl	$1, %eax
	xorl	%edx, %edx
	.p2align 4,,10
	.p2align 3
.L18:
	negq	%rax
	addq	%rax, %rax
	testb	$1, %dl
	jne	.L4
	addq	%rax, %rcx
.L5:
	addl	$1, %edx
	cmpq	%rcx, %rsi
	jl	.L18
	cmpq	%rdi, %rsi
	jg	.L18
.L8:
	movslq	%edx, %rdx
	movl	$1, 16(%rsp,%rdx,4)
	subq	%rax, %rsi
	jne	.L2
	movq	$0, 8(%rsp)
.L3:
	movl	$63, %eax
	jmp	.L9
	.p2align 4,,10
	.p2align 3
.L11:
	subq	$1, %rax
	je	.L10
.L9:
	movl	(%rbx,%rax,4), %ecx
	movslq	%eax, %rdx
	testl	%ecx, %ecx
	je	.L11
	salq	$2, %rdx
	salq	$2, %rax
	leaq	.LC1(%rip), %r12
	leaq	12(%rsp,%rdx), %rbp
	addq	%rdx, %rbx
	subq	%rax, %rbp
	.p2align 4,,10
	.p2align 3
.L12:
	movl	(%rbx), %edx
	movq	%r12, %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	subq	$4, %rbx
	call	__printf_chk@PLT
	cmpq	%rbx, %rbp
	jne	.L12
.L13:
	movq	stdout(%rip), %rdi
	call	fflush@PLT
	movq	280(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L22
	addq	$288, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 32
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L4:
	.cfi_restore_state
	addq	%rax, %rdi
	jmp	.L5
.L10:
	movl	16(%rsp), %edx
	leaq	.LC1(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L13
.L22:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE39:
	.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>
#include <stdlib.h>

int main()
{
	long long N;
	scanf("%lld", &N);

	int i, digit[64] = {};
	long long n, l, u;
	while (N != 0) {
		for (i = 0, n = 1, l = 0, u = 1; N < l || u < N; i++) {
			n *= -2;
			if (i % 2 == 0) l += n;
			else u += n;
		}
		N -= n;
		digit[i] = 1;
	}

	for (i = 63; i > 0 && digit[i] == 0; i--);
	for (; i >= 0; i--) printf("%d", digit[i]);
	fflush(stdout);
	return 0;
}
-1
 208967441
 -6
 -2
 180276081
 -3
 1
 175198680
 -4
 2

11 11101101101011110101100010001 1110 10 11111110000111101110010110001 1101 1 11111101100010101011000101000 1100 110
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>
#include <stdlib.h>

int main()
{
	long long N;
	scanf("%lld", &N);

	int i, digit[64] = {};
	long long n, l, u;
	while (N != 0) {
		for (i = 0, n = 1, l = 0, u = 1; N < l || u < N; i++) {
			n *= -2;
			if (i % 2 == 0) l += n;
			else u += n;
		}
		N -= n;
		digit[i] = 1;
	}

	for (i = 63; i > 0 && digit[i] == 0; i--);
	for (; i >= 0; i--) printf("%d", digit[i]);
	fflush(stdout);
	return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%lld"
.LC1:
	.string	"%d"
	.text
	.globl	main
	.type	main, @function
main:
.LFB6:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$320, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-304(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	leaq	-272(%rbp), %rdx
	movl	$0, %eax
	movl	$32, %ecx
	movq	%rdx, %rdi
	rep stosq
	jmp	.L2
.L7:
	movl	$0, -308(%rbp)
	movq	$1, -296(%rbp)
	movq	$0, -288(%rbp)
	movq	$1, -280(%rbp)
	jmp	.L3
.L6:
	movq	-296(%rbp), %rdx
	movl	$0, %eax
	subq	%rdx, %rax
	addq	%rax, %rax
	movq	%rax, -296(%rbp)
	movl	-308(%rbp), %eax
	andl	$1, %eax
	testl	%eax, %eax
	jne	.L4
	movq	-296(%rbp), %rax
	addq	%rax, -288(%rbp)
	jmp	.L5
.L4:
	movq	-296(%rbp), %rax
	addq	%rax, -280(%rbp)
.L5:
	addl	$1, -308(%rbp)
.L3:
	movq	-304(%rbp), %rax
	cmpq	%rax, -288(%rbp)
	jg	.L6
	movq	-304(%rbp), %rax
	cmpq	%rax, -280(%rbp)
	jl	.L6
	movq	-304(%rbp), %rax
	subq	-296(%rbp), %rax
	movq	%rax, -304(%rbp)
	movl	-308(%rbp), %eax
	cltq
	movl	$1, -272(%rbp,%rax,4)
.L2:
	movq	-304(%rbp), %rax
	testq	%rax, %rax
	jne	.L7
	movl	$63, -308(%rbp)
	jmp	.L8
.L10:
	subl	$1, -308(%rbp)
.L8:
	cmpl	$0, -308(%rbp)
	jle	.L11
	movl	-308(%rbp), %eax
	cltq
	movl	-272(%rbp,%rax,4), %eax
	testl	%eax, %eax
	je	.L10
	jmp	.L11
.L12:
	movl	-308(%rbp), %eax
	cltq
	movl	-272(%rbp,%rax,4), %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	subl	$1, -308(%rbp)
.L11:
	cmpl	$0, -308(%rbp)
	jns	.L12
	movq	stdout(%rip), %rax
	movq	%rax, %rdi
	call	fflush@PLT
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L14
	call	__stack_chk_fail@PLT
.L14:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.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	"%lld"
.LC1:
	.string	"%d"
	.text
	.globl	main
	.type	main, @function
main:
.LFB6:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$320, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-304(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	leaq	-272(%rbp), %rdx
	movl	$0, %eax
	movl	$32, %ecx
	movq	%rdx, %rdi
	rep stosq
	jmp	.L2
.L7:
	movl	$0, -308(%rbp)
	movq	$1, -296(%rbp)
	movq	$0, -288(%rbp)
	movq	$1, -280(%rbp)
	jmp	.L3
.L6:
	movq	-296(%rbp), %rdx
	movl	$0, %eax
	subq	%rdx, %rax
	addq	%rax, %rax
	movq	%rax, -296(%rbp)
	movl	-308(%rbp), %eax
	andl	$1, %eax
	testl	%eax, %eax
	jne	.L4
	movq	-296(%rbp), %rax
	addq	%rax, -288(%rbp)
	jmp	.L5
.L4:
	movq	-296(%rbp), %rax
	addq	%rax, -280(%rbp)
.L5:
	addl	$1, -308(%rbp)
.L3:
	movq	-304(%rbp), %rax
	cmpq	%rax, -288(%rbp)
	jg	.L6
	movq	-304(%rbp), %rax
	cmpq	%rax, -280(%rbp)
	jl	.L6
	movq	-304(%rbp), %rax
	subq	-296(%rbp), %rax
	movq	%rax, -304(%rbp)
	movl	-308(%rbp), %eax
	cltq
	movl	$1, -272(%rbp,%rax,4)
.L2:
	movq	-304(%rbp), %rax
	testq	%rax, %rax
	jne	.L7
	movl	$63, -308(%rbp)
	jmp	.L8
.L10:
	subl	$1, -308(%rbp)
.L8:
	cmpl	$0, -308(%rbp)
	jle	.L11
	movl	-308(%rbp), %eax
	cltq
	movl	-272(%rbp,%rax,4), %eax
	testl	%eax, %eax
	je	.L10
	jmp	.L11
.L12:
	movl	-308(%rbp), %eax
	cltq
	movl	-272(%rbp,%rax,4), %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	subl	$1, -308(%rbp)
.L11:
	cmpl	$0, -308(%rbp)
	jns	.L12
	movq	stdout(%rip), %rax
	movq	%rax, %rdi
	call	fflush@PLT
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L14
	call	__stack_chk_fail@PLT
.L14:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.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:
