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>
typedef long long ll;
#define abs(x) ((x) > 0 ? (x) : -(x))

int
main(int argc, char *argv[])
{
  int n; char s[100000] = {};
  scanf("%d", &n);
  int i = 0;
  if(n == 0) printf("0\n");
  else{
    while(n != 0){
      s[i++] = '0' + abs(n % 2);
      n = (n - abs(n % 2)) / (-2);
    }
    for(int j = 0; j < i; j++){
      printf("%c", s[i - 1 - j]);
    }
    printf("\n");
  }
  return 0;
}
     ```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"0"
	.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
	leaq	-98304(%rsp), %r11
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	subq	$1744, %rsp
	movl	%edi, -100036(%rbp)
	movq	%rsi, -100048(%rbp)
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movq	$0, -100016(%rbp)
	movq	$0, -100008(%rbp)
	leaq	-100000(%rbp), %rax
	movl	$99984, %edx
	movl	$0, %esi
	movq	%rax, %rdi
	call	memset@PLT
	leaq	-100028(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -100024(%rbp)
	movl	-100028(%rbp), %eax
	testl	%eax, %eax
	jne	.L4
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	jmp	.L3
.L5:
	movl	-100028(%rbp), %eax
	cltd
	shrl	$31, %edx
	addl	%edx, %eax
	andl	$1, %eax
	subl	%edx, %eax
	movl	%eax, %edx
	negl	%edx
	cmovns	%edx, %eax
	leal	48(%rax), %ecx
	movl	-100024(%rbp), %eax
	leal	1(%rax), %edx
	movl	%edx, -100024(%rbp)
	movl	%ecx, %edx
	cltq
	movb	%dl, -100016(%rbp,%rax)
	movl	-100028(%rbp), %edx
	movl	-100028(%rbp), %eax
	movl	%eax, %ecx
	sarl	$31, %ecx
	shrl	$31, %ecx
	addl	%ecx, %eax
	andl	$1, %eax
	subl	%ecx, %eax
	movl	%eax, %ecx
	negl	%ecx
	cmovs	%eax, %ecx
	movl	%edx, %eax
	subl	%ecx, %eax
	movl	%eax, %edx
	shrl	$31, %edx
	addl	%edx, %eax
	sarl	%eax
	negl	%eax
	movl	%eax, -100028(%rbp)
.L4:
	movl	-100028(%rbp), %eax
	testl	%eax, %eax
	jne	.L5
	movl	$0, -100020(%rbp)
	jmp	.L6
.L7:
	movl	-100024(%rbp), %eax
	subl	$1, %eax
	subl	-100020(%rbp), %eax
	cltq
	movzbl	-100016(%rbp,%rax), %eax
	movsbl	%al, %eax
	movl	%eax, %edi
	call	putchar@PLT
	addl	$1, -100020(%rbp)
.L6:
	movl	-100020(%rbp), %eax
	cmpl	-100024(%rbp), %eax
	jl	.L7
	movl	$10, %edi
	call	putchar@PLT
.L3:
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L9
	call	__stack_chk_fail@PLT
.L9:
	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	"0"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB23:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	pushq	%rbx
	.cfi_def_cfa_offset 24
	.cfi_offset 3, -24
	leaq	-98304(%rsp), %r11
	.cfi_def_cfa 11, 98328
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	.cfi_def_cfa_register 7
	subq	$1736, %rsp
	.cfi_def_cfa_offset 100064
	pxor	%xmm0, %xmm0
	movl	$99984, %edx
	xorl	%esi, %esi
	movq	%fs:40, %rax
	movq	%rax, 100024(%rsp)
	xorl	%eax, %eax
	leaq	32(%rsp), %rdi
	movaps	%xmm0, 16(%rsp)
	leaq	16(%rsp), %rbx
	call	memset@PLT
	leaq	12(%rsp), %rsi
	leaq	.LC0(%rip), %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	12(%rsp), %eax
	xorl	%ecx, %ecx
	testl	%eax, %eax
	je	.L13
	.p2align 4,,10
	.p2align 3
.L2:
	movl	%eax, %esi
	movslq	%ecx, %rdi
	shrl	$31, %esi
	leal	(%rax,%rsi), %edx
	andl	$1, %edx
	subl	%esi, %edx
	movl	%edx, %esi
	negl	%esi
	cmovns	%esi, %edx
	subl	%edx, %eax
	leal	48(%rdx), %esi
	movl	%eax, %edx
	movb	%sil, (%rbx,%rcx)
	shrl	$31, %edx
	addl	%edx, %eax
	movq	%rcx, %rdx
	addq	$1, %rcx
	sarl	%eax
	negl	%eax
	jne	.L2
	movl	$0, 12(%rsp)
	leaq	15(%rsp,%rdi), %rbp
	addq	%rdi, %rbx
	subq	%rdx, %rbp
	.p2align 4,,10
	.p2align 3
.L4:
	movsbl	(%rbx), %edi
	subq	$1, %rbx
	call	putchar@PLT
	cmpq	%rbx, %rbp
	jne	.L4
	movl	$10, %edi
	call	putchar@PLT
.L3:
	movq	100024(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L14
	addq	$100040, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 24
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	ret
.L13:
	.cfi_restore_state
	leaq	.LC1(%rip), %rdi
	call	puts@PLT
	jmp	.L3
.L14:
	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	"0"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB23:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	pushq	%rbx
	.cfi_def_cfa_offset 24
	.cfi_offset 3, -24
	leaq	-98304(%rsp), %r11
	.cfi_def_cfa 11, 98328
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	.cfi_def_cfa_register 7
	subq	$1736, %rsp
	.cfi_def_cfa_offset 100064
	pxor	%xmm0, %xmm0
	movl	$99984, %edx
	xorl	%esi, %esi
	movq	%fs:40, %rax
	movq	%rax, 100024(%rsp)
	xorl	%eax, %eax
	leaq	32(%rsp), %rdi
	movaps	%xmm0, 16(%rsp)
	leaq	16(%rsp), %rbx
	call	memset@PLT
	leaq	12(%rsp), %rsi
	leaq	.LC0(%rip), %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	12(%rsp), %eax
	xorl	%ecx, %ecx
	testl	%eax, %eax
	je	.L13
	.p2align 4,,10
	.p2align 3
.L2:
	movl	%eax, %esi
	movslq	%ecx, %rdi
	shrl	$31, %esi
	leal	(%rax,%rsi), %edx
	andl	$1, %edx
	subl	%esi, %edx
	movl	%edx, %esi
	negl	%esi
	cmovns	%esi, %edx
	subl	%edx, %eax
	leal	48(%rdx), %esi
	movl	%eax, %edx
	movb	%sil, (%rbx,%rcx)
	shrl	$31, %edx
	addl	%edx, %eax
	movq	%rcx, %rdx
	addq	$1, %rcx
	sarl	%eax
	negl	%eax
	jne	.L2
	movl	$0, 12(%rsp)
	leaq	15(%rsp,%rdi), %rbp
	addq	%rdi, %rbx
	subq	%rdx, %rbp
	.p2align 4,,10
	.p2align 3
.L4:
	movsbl	(%rbx), %edi
	subq	$1, %rbx
	call	putchar@PLT
	cmpq	%rbx, %rbp
	jne	.L4
	movl	$10, %edi
	call	putchar@PLT
.L3:
	movq	100024(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L14
	addq	$100040, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 24
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	ret
.L13:
	.cfi_restore_state
	leaq	.LC1(%rip), %rdi
	call	puts@PLT
	jmp	.L3
.L14:
	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>
typedef long long ll;
#define abs(x) ((x) > 0 ? (x) : -(x))

int
main(int argc, char *argv[])
{
  int n; char s[100000] = {};
  scanf("%d", &n);
  int i = 0;
  if(n == 0) printf("0\n");
  else{
    while(n != 0){
      s[i++] = '0' + abs(n % 2);
      n = (n - abs(n % 2)) / (-2);
    }
    for(int j = 0; j < i; j++){
      printf("%c", s[i - 1 - j]);
    }
    printf("\n");
  }
  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>
typedef long long ll;
#define abs(x) ((x) > 0 ? (x) : -(x))

int
main(int argc, char *argv[])
{
  int n; char s[100000] = {};
  scanf("%d", &n);
  int i = 0;
  if(n == 0) printf("0\n");
  else{
    while(n != 0){
      s[i++] = '0' + abs(n % 2);
      n = (n - abs(n % 2)) / (-2);
    }
    for(int j = 0; j < i; j++){
      printf("%c", s[i - 1 - j]);
    }
    printf("\n");
  }
  return 0;
}
     ```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"0"
	.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
	leaq	-98304(%rsp), %r11
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	subq	$1744, %rsp
	movl	%edi, -100036(%rbp)
	movq	%rsi, -100048(%rbp)
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movq	$0, -100016(%rbp)
	movq	$0, -100008(%rbp)
	leaq	-100000(%rbp), %rax
	movl	$99984, %edx
	movl	$0, %esi
	movq	%rax, %rdi
	call	memset@PLT
	leaq	-100028(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -100024(%rbp)
	movl	-100028(%rbp), %eax
	testl	%eax, %eax
	jne	.L4
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	jmp	.L3
.L5:
	movl	-100028(%rbp), %eax
	cltd
	shrl	$31, %edx
	addl	%edx, %eax
	andl	$1, %eax
	subl	%edx, %eax
	movl	%eax, %edx
	negl	%edx
	cmovns	%edx, %eax
	leal	48(%rax), %ecx
	movl	-100024(%rbp), %eax
	leal	1(%rax), %edx
	movl	%edx, -100024(%rbp)
	movl	%ecx, %edx
	cltq
	movb	%dl, -100016(%rbp,%rax)
	movl	-100028(%rbp), %edx
	movl	-100028(%rbp), %eax
	movl	%eax, %ecx
	sarl	$31, %ecx
	shrl	$31, %ecx
	addl	%ecx, %eax
	andl	$1, %eax
	subl	%ecx, %eax
	movl	%eax, %ecx
	negl	%ecx
	cmovs	%eax, %ecx
	movl	%edx, %eax
	subl	%ecx, %eax
	movl	%eax, %edx
	shrl	$31, %edx
	addl	%edx, %eax
	sarl	%eax
	negl	%eax
	movl	%eax, -100028(%rbp)
.L4:
	movl	-100028(%rbp), %eax
	testl	%eax, %eax
	jne	.L5
	movl	$0, -100020(%rbp)
	jmp	.L6
.L7:
	movl	-100024(%rbp), %eax
	subl	$1, %eax
	subl	-100020(%rbp), %eax
	cltq
	movzbl	-100016(%rbp,%rax), %eax
	movsbl	%al, %eax
	movl	%eax, %edi
	call	putchar@PLT
	addl	$1, -100020(%rbp)
.L6:
	movl	-100020(%rbp), %eax
	cmpl	-100024(%rbp), %eax
	jl	.L7
	movl	$10, %edi
	call	putchar@PLT
.L3:
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L9
	call	__stack_chk_fail@PLT
.L9:
	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	"0"
	.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
	leaq	-98304(%rsp), %r11
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	subq	$1744, %rsp
	movl	%edi, -100036(%rbp)
	movq	%rsi, -100048(%rbp)
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movq	$0, -100016(%rbp)
	movq	$0, -100008(%rbp)
	leaq	-100000(%rbp), %rax
	movl	$99984, %edx
	movl	$0, %esi
	movq	%rax, %rdi
	call	memset@PLT
	leaq	-100028(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -100024(%rbp)
	movl	-100028(%rbp), %eax
	testl	%eax, %eax
	jne	.L4
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	jmp	.L3
.L5:
	movl	-100028(%rbp), %eax
	cltd
	shrl	$31, %edx
	addl	%edx, %eax
	andl	$1, %eax
	subl	%edx, %eax
	movl	%eax, %edx
	negl	%edx
	cmovns	%edx, %eax
	leal	48(%rax), %ecx
	movl	-100024(%rbp), %eax
	leal	1(%rax), %edx
	movl	%edx, -100024(%rbp)
	movl	%ecx, %edx
	cltq
	movb	%dl, -100016(%rbp,%rax)
	movl	-100028(%rbp), %edx
	movl	-100028(%rbp), %eax
	movl	%eax, %ecx
	sarl	$31, %ecx
	shrl	$31, %ecx
	addl	%ecx, %eax
	andl	$1, %eax
	subl	%ecx, %eax
	movl	%eax, %ecx
	negl	%ecx
	cmovs	%eax, %ecx
	movl	%edx, %eax
	subl	%ecx, %eax
	movl	%eax, %edx
	shrl	$31, %edx
	addl	%edx, %eax
	sarl	%eax
	negl	%eax
	movl	%eax, -100028(%rbp)
.L4:
	movl	-100028(%rbp), %eax
	testl	%eax, %eax
	jne	.L5
	movl	$0, -100020(%rbp)
	jmp	.L6
.L7:
	movl	-100024(%rbp), %eax
	subl	$1, %eax
	subl	-100020(%rbp), %eax
	cltq
	movzbl	-100016(%rbp,%rax), %eax
	movsbl	%al, %eax
	movl	%eax, %edi
	call	putchar@PLT
	addl	$1, -100020(%rbp)
.L6:
	movl	-100020(%rbp), %eax
	cmpl	-100024(%rbp), %eax
	jl	.L7
	movl	$10, %edi
	call	putchar@PLT
.L3:
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L9
	call	__stack_chk_fail@PLT
.L9:
	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:
