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(){
  long n,left,right,mid;
  scanf("%ld",&n);
  left=1;
  right=n;
  mid=(left+right)/2;
  while(left<right){
    mid=(left+right)/2;
    if(n-mid>mid*(mid-1)/2)
      left=mid+1;
    else if(n-mid<mid*(mid-1)/2)
      right=mid;
    else
      left=right=mid;
  }
  for(long i=1;i<=left;i++)
    if(i!=(left*(left+1)/2)-n)
      printf("%ld\n",i);
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%ld"
.LC1:
	.string	"%ld\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	$48, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-48(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movq	$1, -40(%rbp)
	movq	-48(%rbp), %rax
	movq	%rax, -32(%rbp)
	movq	-40(%rbp), %rdx
	movq	-32(%rbp), %rax
	addq	%rdx, %rax
	movq	%rax, %rdx
	shrq	$63, %rdx
	addq	%rdx, %rax
	sarq	%rax
	movq	%rax, -16(%rbp)
	jmp	.L2
.L5:
	movq	-40(%rbp), %rdx
	movq	-32(%rbp), %rax
	addq	%rdx, %rax
	movq	%rax, %rdx
	shrq	$63, %rdx
	addq	%rdx, %rax
	sarq	%rax
	movq	%rax, -16(%rbp)
	movq	-48(%rbp), %rax
	subq	-16(%rbp), %rax
	movq	%rax, %rdx
	movq	-16(%rbp), %rax
	subq	$1, %rax
	imulq	-16(%rbp), %rax
	movq	%rax, %rcx
	shrq	$63, %rcx
	addq	%rcx, %rax
	sarq	%rax
	cmpq	%rax, %rdx
	jle	.L3
	movq	-16(%rbp), %rax
	addq	$1, %rax
	movq	%rax, -40(%rbp)
	jmp	.L2
.L3:
	movq	-48(%rbp), %rax
	subq	-16(%rbp), %rax
	movq	%rax, %rdx
	movq	-16(%rbp), %rax
	subq	$1, %rax
	imulq	-16(%rbp), %rax
	movq	%rax, %rcx
	shrq	$63, %rcx
	addq	%rcx, %rax
	sarq	%rax
	cmpq	%rax, %rdx
	jge	.L4
	movq	-16(%rbp), %rax
	movq	%rax, -32(%rbp)
	jmp	.L2
.L4:
	movq	-16(%rbp), %rax
	movq	%rax, -32(%rbp)
	movq	-32(%rbp), %rax
	movq	%rax, -40(%rbp)
.L2:
	movq	-40(%rbp), %rax
	cmpq	-32(%rbp), %rax
	jl	.L5
	movq	$1, -24(%rbp)
	jmp	.L6
.L8:
	movq	-40(%rbp), %rax
	addq	$1, %rax
	imulq	-40(%rbp), %rax
	movq	%rax, %rdx
	shrq	$63, %rdx
	addq	%rdx, %rax
	sarq	%rax
	movq	-48(%rbp), %rdx
	subq	%rdx, %rax
	cmpq	%rax, -24(%rbp)
	je	.L7
	movq	-24(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L7:
	addq	$1, -24(%rbp)
.L6:
	movq	-24(%rbp), %rax
	cmpq	-40(%rbp), %rax
	jle	.L8
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L10
	call	__stack_chk_fail@PLT
.L10:
	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	"%ld"
.LC1:
	.string	"%ld\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	$24, %rsp
	.cfi_def_cfa_offset 64
	movq	%fs:40, %rax
	movq	%rax, 8(%rsp)
	xorl	%eax, %eax
	movq	%rsp, %rsi
	call	__isoc99_scanf@PLT
	movq	(%rsp), %rdx
	cmpq	$1, %rdx
	jle	.L12
	movq	%rdx, %rsi
	movl	$1, %ecx
	jmp	.L6
	.p2align 4,,10
	.p2align 3
.L18:
	leaq	1(%rbx), %rcx
.L4:
	cmpq	%rcx, %rsi
	jle	.L17
.L6:
	leaq	(%rsi,%rcx), %rbx
	movq	%rdx, %rdi
	sarq	%rbx
	leaq	-1(%rbx), %rax
	subq	%rbx, %rdi
	imulq	%rbx, %rax
	sarq	%rax
	cmpq	%rax, %rdi
	jg	.L18
	jl	.L19
.L2:
	leaq	1(%rbx), %r12
	movl	$1, %ebp
	leaq	.LC1(%rip), %r13
	imulq	%rbx, %r12
	sarq	%r12
	.p2align 4,,10
	.p2align 3
.L10:
	movq	%r12, %rax
	subq	%rdx, %rax
	cmpq	%rbp, %rax
	je	.L7
.L20:
	movq	%rbp, %rdx
	movq	%r13, %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	addq	$1, %rbp
	cmpq	%rbp, %rbx
	jl	.L9
	movq	(%rsp), %rdx
	movq	%r12, %rax
	subq	%rdx, %rax
	cmpq	%rbp, %rax
	jne	.L20
.L7:
	addq	$1, %rbp
	cmpq	%rbp, %rbx
	jge	.L10
.L9:
	movq	8(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L21
	addq	$24, %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
	.p2align 4,,10
	.p2align 3
.L19:
	.cfi_restore_state
	movq	%rbx, %rsi
	jmp	.L4
.L12:
	movl	$1, %ebx
	jmp	.L2
.L17:
	movq	%rcx, %rbx
	jmp	.L2
.L21:
	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	"%ld"
.LC1:
	.string	"%ld\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	$24, %rsp
	.cfi_def_cfa_offset 64
	movq	%fs:40, %rax
	movq	%rax, 8(%rsp)
	xorl	%eax, %eax
	movq	%rsp, %rsi
	call	__isoc99_scanf@PLT
	movq	(%rsp), %rdx
	cmpq	$1, %rdx
	jle	.L12
	movq	%rdx, %rsi
	movl	$1, %ecx
	jmp	.L6
	.p2align 4,,10
	.p2align 3
.L18:
	leaq	1(%rbx), %rcx
.L4:
	cmpq	%rcx, %rsi
	jle	.L17
.L6:
	leaq	(%rsi,%rcx), %rbx
	movq	%rdx, %rdi
	sarq	%rbx
	leaq	-1(%rbx), %rax
	subq	%rbx, %rdi
	imulq	%rbx, %rax
	sarq	%rax
	cmpq	%rax, %rdi
	jg	.L18
	jl	.L19
.L2:
	leaq	1(%rbx), %r12
	movl	$1, %ebp
	leaq	.LC1(%rip), %r13
	imulq	%rbx, %r12
	sarq	%r12
	.p2align 4,,10
	.p2align 3
.L10:
	movq	%r12, %rax
	subq	%rdx, %rax
	cmpq	%rbp, %rax
	je	.L7
.L20:
	movq	%rbp, %rdx
	movq	%r13, %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	addq	$1, %rbp
	cmpq	%rbp, %rbx
	jl	.L9
	movq	(%rsp), %rdx
	movq	%r12, %rax
	subq	%rdx, %rax
	cmpq	%rbp, %rax
	jne	.L20
.L7:
	addq	$1, %rbp
	cmpq	%rbp, %rbx
	jge	.L10
.L9:
	movq	8(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L21
	addq	$24, %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
	.p2align 4,,10
	.p2align 3
.L19:
	.cfi_restore_state
	movq	%rbx, %rsi
	jmp	.L4
.L12:
	movl	$1, %ebx
	jmp	.L2
.L17:
	movq	%rcx, %rbx
	jmp	.L2
.L21:
	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(){
  long n,left,right,mid;
  scanf("%ld",&n);
  left=1;
  right=n;
  mid=(left+right)/2;
  while(left<right){
    mid=(left+right)/2;
    if(n-mid>mid*(mid-1)/2)
      left=mid+1;
    else if(n-mid<mid*(mid-1)/2)
      right=mid;
    else
      left=right=mid;
  }
  for(long i=1;i<=left;i++)
    if(i!=(left*(left+1)/2)-n)
      printf("%ld\n",i);
}
14
 2
 3
 8
 12
 21
 5
 9
 17
 31

2
3
4
5
 2
 1
2
 1
3
4
 1
2
4
5
 1
2
3
4
5
6
 2
3
 2
3
4
 1
2
3
5
6
 1
2
3
4
6
7
8

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(){
  long n,left,right,mid;
  scanf("%ld",&n);
  left=1;
  right=n;
  mid=(left+right)/2;
  while(left<right){
    mid=(left+right)/2;
    if(n-mid>mid*(mid-1)/2)
      left=mid+1;
    else if(n-mid<mid*(mid-1)/2)
      right=mid;
    else
      left=right=mid;
  }
  for(long i=1;i<=left;i++)
    if(i!=(left*(left+1)/2)-n)
      printf("%ld\n",i);
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%ld"
.LC1:
	.string	"%ld\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	$48, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-48(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movq	$1, -40(%rbp)
	movq	-48(%rbp), %rax
	movq	%rax, -32(%rbp)
	movq	-40(%rbp), %rdx
	movq	-32(%rbp), %rax
	addq	%rdx, %rax
	movq	%rax, %rdx
	shrq	$63, %rdx
	addq	%rdx, %rax
	sarq	%rax
	movq	%rax, -16(%rbp)
	jmp	.L2
.L5:
	movq	-40(%rbp), %rdx
	movq	-32(%rbp), %rax
	addq	%rdx, %rax
	movq	%rax, %rdx
	shrq	$63, %rdx
	addq	%rdx, %rax
	sarq	%rax
	movq	%rax, -16(%rbp)
	movq	-48(%rbp), %rax
	subq	-16(%rbp), %rax
	movq	%rax, %rdx
	movq	-16(%rbp), %rax
	subq	$1, %rax
	imulq	-16(%rbp), %rax
	movq	%rax, %rcx
	shrq	$63, %rcx
	addq	%rcx, %rax
	sarq	%rax
	cmpq	%rax, %rdx
	jle	.L3
	movq	-16(%rbp), %rax
	addq	$1, %rax
	movq	%rax, -40(%rbp)
	jmp	.L2
.L3:
	movq	-48(%rbp), %rax
	subq	-16(%rbp), %rax
	movq	%rax, %rdx
	movq	-16(%rbp), %rax
	subq	$1, %rax
	imulq	-16(%rbp), %rax
	movq	%rax, %rcx
	shrq	$63, %rcx
	addq	%rcx, %rax
	sarq	%rax
	cmpq	%rax, %rdx
	jge	.L4
	movq	-16(%rbp), %rax
	movq	%rax, -32(%rbp)
	jmp	.L2
.L4:
	movq	-16(%rbp), %rax
	movq	%rax, -32(%rbp)
	movq	-32(%rbp), %rax
	movq	%rax, -40(%rbp)
.L2:
	movq	-40(%rbp), %rax
	cmpq	-32(%rbp), %rax
	jl	.L5
	movq	$1, -24(%rbp)
	jmp	.L6
.L8:
	movq	-40(%rbp), %rax
	addq	$1, %rax
	imulq	-40(%rbp), %rax
	movq	%rax, %rdx
	shrq	$63, %rdx
	addq	%rdx, %rax
	sarq	%rax
	movq	-48(%rbp), %rdx
	subq	%rdx, %rax
	cmpq	%rax, -24(%rbp)
	je	.L7
	movq	-24(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L7:
	addq	$1, -24(%rbp)
.L6:
	movq	-24(%rbp), %rax
	cmpq	-40(%rbp), %rax
	jle	.L8
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L10
	call	__stack_chk_fail@PLT
.L10:
	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.
val
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%ld"
.LC1:
	.string	"%ld\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	$48, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-48(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movq	$1, -40(%rbp)
	movq	-48(%rbp), %rax
	movq	%rax, -32(%rbp)
	movq	-40(%rbp), %rdx
	movq	-32(%rbp), %rax
	addq	%rdx, %rax
	movq	%rax, %rdx
	shrq	$63, %rdx
	addq	%rdx, %rax
	sarq	%rax
	movq	%rax, -16(%rbp)
	jmp	.L2
.L5:
	movq	-40(%rbp), %rdx
	movq	-32(%rbp), %rax
	addq	%rdx, %rax
	movq	%rax, %rdx
	shrq	$63, %rdx
	addq	%rdx, %rax
	sarq	%rax
	movq	%rax, -16(%rbp)
	movq	-48(%rbp), %rax
	subq	-16(%rbp), %rax
	movq	%rax, %rdx
	movq	-16(%rbp), %rax
	subq	$1, %rax
	imulq	-16(%rbp), %rax
	movq	%rax, %rcx
	shrq	$63, %rcx
	addq	%rcx, %rax
	sarq	%rax
	cmpq	%rax, %rdx
	jle	.L3
	movq	-16(%rbp), %rax
	addq	$1, %rax
	movq	%rax, -40(%rbp)
	jmp	.L2
.L3:
	movq	-48(%rbp), %rax
	subq	-16(%rbp), %rax
	movq	%rax, %rdx
	movq	-16(%rbp), %rax
	subq	$1, %rax
	imulq	-16(%rbp), %rax
	movq	%rax, %rcx
	shrq	$63, %rcx
	addq	%rcx, %rax
	sarq	%rax
	cmpq	%rax, %rdx
	jge	.L4
	movq	-16(%rbp), %rax
	movq	%rax, -32(%rbp)
	jmp	.L2
.L4:
	movq	-16(%rbp), %rax
	movq	%rax, -32(%rbp)
	movq	-32(%rbp), %rax
	movq	%rax, -40(%rbp)
.L2:
	movq	-40(%rbp), %rax
	cmpq	-32(%rbp), %rax
	jl	.L5
	movq	$1, -24(%rbp)
	jmp	.L6
.L8:
	movq	-40(%rbp), %rax
	addq	$1, %rax
	imulq	-40(%rbp), %rax
	movq	%rax, %rdx
	shrq	$63, %rdx
	addq	%rdx, %rax
	sarq	%rax
	movq	-48(%rbp), %rdx
	subq	%rdx, %rax
	cmpq	%rax, -24(%rbp)
	je	.L7
	movq	-24(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L7:
	addq	$1, -24(%rbp)
.L6:
	movq	-24(%rbp), %rax
	cmpq	-40(%rbp), %rax
	jle	.L8
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L10
	call	__stack_chk_fail@PLT
.L10:
	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:
