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, u, w;
	long long ans = 0, tmp;
	scanf("%d", &N);
	for (i = 1; i <= N; i++) ans += (long long)(N - i + 2) * (N - i + 1) / 2;
	for (i = 1; i <= N - 1; i++) {
		scanf("%d %d", &u, &w);
		if (u > w) {
			u ^= w;
			w ^= u;
			u ^= w;
		}
		ans -= (long long)u * (N - w + 1);
	}
	printf("%lld\n", ans);
	fflush(stdout);
	return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%d %d"
.LC2:
	.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	$32, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movq	$0, -16(%rbp)
	leaq	-32(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$1, -20(%rbp)
	jmp	.L2
.L3:
	movl	-32(%rbp), %eax
	subl	-20(%rbp), %eax
	addl	$2, %eax
	movslq	%eax, %rdx
	movl	-32(%rbp), %eax
	subl	-20(%rbp), %eax
	addl	$1, %eax
	cltq
	imulq	%rdx, %rax
	movq	%rax, %rdx
	shrq	$63, %rdx
	addq	%rdx, %rax
	sarq	%rax
	addq	%rax, -16(%rbp)
	addl	$1, -20(%rbp)
.L2:
	movl	-32(%rbp), %eax
	cmpl	%eax, -20(%rbp)
	jle	.L3
	movl	$1, -20(%rbp)
	jmp	.L4
.L6:
	leaq	-24(%rbp), %rdx
	leaq	-28(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-28(%rbp), %edx
	movl	-24(%rbp), %eax
	cmpl	%eax, %edx
	jle	.L5
	movl	-28(%rbp), %edx
	movl	-24(%rbp), %eax
	xorl	%edx, %eax
	movl	%eax, -28(%rbp)
	movl	-24(%rbp), %edx
	movl	-28(%rbp), %eax
	xorl	%edx, %eax
	movl	%eax, -24(%rbp)
	movl	-28(%rbp), %edx
	movl	-24(%rbp), %eax
	xorl	%edx, %eax
	movl	%eax, -28(%rbp)
.L5:
	movl	-28(%rbp), %eax
	movslq	%eax, %rdx
	movl	-32(%rbp), %eax
	movl	-24(%rbp), %ecx
	subl	%ecx, %eax
	addl	$1, %eax
	cltq
	imulq	%rdx, %rax
	subq	%rax, -16(%rbp)
	addl	$1, -20(%rbp)
.L4:
	movl	-32(%rbp), %eax
	cmpl	%eax, -20(%rbp)
	jl	.L6
	movq	-16(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movq	stdout(%rip), %rax
	movq	%rax, %rdi
	call	fflush@PLT
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L8
	call	__stack_chk_fail@PLT
.L8:
	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	"%d %d"
.LC2:
	.string	"%lld\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB23:
	.cfi_startproc
	endbr64
	pushq	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	leaq	.LC0(%rip), %rdi
	pushq	%r13
	.cfi_def_cfa_offset 24
	.cfi_offset 13, -24
	pushq	%r12
	.cfi_def_cfa_offset 32
	.cfi_offset 12, -32
	pushq	%rbp
	.cfi_def_cfa_offset 40
	.cfi_offset 6, -40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	subq	$32, %rsp
	.cfi_def_cfa_offset 80
	movq	%fs:40, %rax
	movq	%rax, 24(%rsp)
	xorl	%eax, %eax
	leaq	12(%rsp), %rsi
	call	__isoc99_scanf@PLT
	movl	12(%rsp), %edi
	testl	%edi, %edi
	jle	.L8
	movslq	%edi, %rsi
	leal	-1(%rdi), %eax
	xorl	%r12d, %r12d
	leaq	1(%rsi), %rdx
	subq	%rax, %rsi
	.p2align 4,,10
	.p2align 3
.L3:
	movq	%rdx, %rcx
	subq	$1, %rdx
	imulq	%rdx, %rcx
	movq	%rcx, %rax
	shrq	$63, %rax
	addq	%rcx, %rax
	sarq	%rax
	addq	%rax, %r12
	cmpq	%rdx, %rsi
	jne	.L3
	cmpl	$1, %edi
	jle	.L2
	movl	$1, %r14d
	leaq	20(%rsp), %r13
	leaq	16(%rsp), %rbp
	leaq	.LC1(%rip), %rbx
	jmp	.L6
	.p2align 4,,10
	.p2align 3
.L13:
	movl	12(%rsp), %esi
	movl	%eax, 20(%rsp)
	addl	$1, %r14d
	movl	%edx, 16(%rsp)
	movl	%esi, %ecx
	subl	%eax, %ecx
	leal	1(%rcx), %eax
	cltq
	imulq	%rdx, %rax
	subq	%rax, %r12
	cmpl	%r14d, %esi
	jle	.L2
.L6:
	movq	%r13, %rdx
	movq	%rbp, %rsi
	movq	%rbx, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movslq	16(%rsp), %rax
	movslq	20(%rsp), %rdx
	cmpl	%edx, %eax
	jg	.L13
	movl	12(%rsp), %esi
	addl	$1, %r14d
	movl	%esi, %ecx
	subl	%edx, %ecx
	leal	1(%rcx), %edx
	movslq	%edx, %rdx
	imulq	%rdx, %rax
	subq	%rax, %r12
	cmpl	%r14d, %esi
	jg	.L6
.L2:
	movl	$1, %edi
	xorl	%eax, %eax
	movq	%r12, %rdx
	leaq	.LC2(%rip), %rsi
	call	__printf_chk@PLT
	movq	stdout(%rip), %rdi
	call	fflush@PLT
	movq	24(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L14
	addq	$32, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 48
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%rbp
	.cfi_def_cfa_offset 32
	popq	%r12
	.cfi_def_cfa_offset 24
	popq	%r13
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	ret
.L8:
	.cfi_restore_state
	xorl	%r12d, %r12d
	jmp	.L2
.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	"%d %d"
.LC2:
	.string	"%lld\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB23:
	.cfi_startproc
	endbr64
	pushq	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	leaq	.LC0(%rip), %rdi
	pushq	%r13
	.cfi_def_cfa_offset 24
	.cfi_offset 13, -24
	pushq	%r12
	.cfi_def_cfa_offset 32
	.cfi_offset 12, -32
	pushq	%rbp
	.cfi_def_cfa_offset 40
	.cfi_offset 6, -40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	subq	$32, %rsp
	.cfi_def_cfa_offset 80
	movq	%fs:40, %rax
	movq	%rax, 24(%rsp)
	xorl	%eax, %eax
	leaq	12(%rsp), %rsi
	call	__isoc99_scanf@PLT
	movl	12(%rsp), %edi
	testl	%edi, %edi
	jle	.L8
	movslq	%edi, %rsi
	leal	-1(%rdi), %eax
	xorl	%r12d, %r12d
	leaq	1(%rsi), %rdx
	subq	%rax, %rsi
	.p2align 4,,10
	.p2align 3
.L3:
	movq	%rdx, %rcx
	subq	$1, %rdx
	imulq	%rdx, %rcx
	movq	%rcx, %rax
	shrq	$63, %rax
	addq	%rcx, %rax
	sarq	%rax
	addq	%rax, %r12
	cmpq	%rdx, %rsi
	jne	.L3
	cmpl	$1, %edi
	jle	.L2
	movl	$1, %r14d
	leaq	20(%rsp), %r13
	leaq	16(%rsp), %rbp
	leaq	.LC1(%rip), %rbx
	jmp	.L6
	.p2align 4,,10
	.p2align 3
.L13:
	movl	12(%rsp), %esi
	movl	%eax, 20(%rsp)
	addl	$1, %r14d
	movl	%edx, 16(%rsp)
	movl	%esi, %ecx
	subl	%eax, %ecx
	leal	1(%rcx), %eax
	cltq
	imulq	%rdx, %rax
	subq	%rax, %r12
	cmpl	%r14d, %esi
	jle	.L2
.L6:
	movq	%r13, %rdx
	movq	%rbp, %rsi
	movq	%rbx, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movslq	16(%rsp), %rax
	movslq	20(%rsp), %rdx
	cmpl	%edx, %eax
	jg	.L13
	movl	12(%rsp), %esi
	addl	$1, %r14d
	movl	%esi, %ecx
	subl	%edx, %ecx
	leal	1(%rcx), %edx
	movslq	%edx, %rdx
	imulq	%rdx, %rax
	subq	%rax, %r12
	cmpl	%r14d, %esi
	jg	.L6
.L2:
	movl	$1, %edi
	xorl	%eax, %eax
	movq	%r12, %rdx
	leaq	.LC2(%rip), %rsi
	call	__printf_chk@PLT
	movq	stdout(%rip), %rdi
	call	fflush@PLT
	movq	24(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L14
	addq	$32, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 48
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%rbp
	.cfi_def_cfa_offset 32
	popq	%r12
	.cfi_def_cfa_offset 24
	popq	%r13
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	ret
.L8:
	.cfi_restore_state
	xorl	%r12d, %r12d
	jmp	.L2
.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>

int main()
{
	int i, N, u, w;
	long long ans = 0, tmp;
	scanf("%d", &N);
	for (i = 1; i <= N; i++) ans += (long long)(N - i + 2) * (N - i + 1) / 2;
	for (i = 1; i <= N - 1; i++) {
		scanf("%d %d", &u, &w);
		if (u > w) {
			u ^= w;
			w ^= u;
			u ^= w;
		}
		ans -= (long long)u * (N - w + 1);
	}
	printf("%lld\n", ans);
	fflush(stdout);
	return 0;
}
2
0 2
 10
5 3
5 7
8 9
0 9
9 10
8 4
7 4
6 10
7 2
 3
1 3
0 3
 10
5 3
5 7
8 9
0 9
12 10
8 4
7 4
6 10
7 2
 2
-1 1
 10
5 3
5 7
8 9
0 9
12 10
4 4
7 4
6 10
7 2
 2
-1 2
 3
1 0
0 6
 10
5 3
5 7
0 9
0 9
12 10
4 7
7 4
6 10
7 2
 10
5 3
5 7
-1 9
0 9
12 10
4 7
7 4
6 10
7 2

4
 115
 9
 134
 6
 118
 5
 10
 146
 148

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, u, w;
	long long ans = 0, tmp;
	scanf("%d", &N);
	for (i = 1; i <= N; i++) ans += (long long)(N - i + 2) * (N - i + 1) / 2;
	for (i = 1; i <= N - 1; i++) {
		scanf("%d %d", &u, &w);
		if (u > w) {
			u ^= w;
			w ^= u;
			u ^= w;
		}
		ans -= (long long)u * (N - w + 1);
	}
	printf("%lld\n", ans);
	fflush(stdout);
	return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%d %d"
.LC2:
	.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	$32, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movq	$0, -16(%rbp)
	leaq	-32(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$1, -20(%rbp)
	jmp	.L2
.L3:
	movl	-32(%rbp), %eax
	subl	-20(%rbp), %eax
	addl	$2, %eax
	movslq	%eax, %rdx
	movl	-32(%rbp), %eax
	subl	-20(%rbp), %eax
	addl	$1, %eax
	cltq
	imulq	%rdx, %rax
	movq	%rax, %rdx
	shrq	$63, %rdx
	addq	%rdx, %rax
	sarq	%rax
	addq	%rax, -16(%rbp)
	addl	$1, -20(%rbp)
.L2:
	movl	-32(%rbp), %eax
	cmpl	%eax, -20(%rbp)
	jle	.L3
	movl	$1, -20(%rbp)
	jmp	.L4
.L6:
	leaq	-24(%rbp), %rdx
	leaq	-28(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-28(%rbp), %edx
	movl	-24(%rbp), %eax
	cmpl	%eax, %edx
	jle	.L5
	movl	-28(%rbp), %edx
	movl	-24(%rbp), %eax
	xorl	%edx, %eax
	movl	%eax, -28(%rbp)
	movl	-24(%rbp), %edx
	movl	-28(%rbp), %eax
	xorl	%edx, %eax
	movl	%eax, -24(%rbp)
	movl	-28(%rbp), %edx
	movl	-24(%rbp), %eax
	xorl	%edx, %eax
	movl	%eax, -28(%rbp)
.L5:
	movl	-28(%rbp), %eax
	movslq	%eax, %rdx
	movl	-32(%rbp), %eax
	movl	-24(%rbp), %ecx
	subl	%ecx, %eax
	addl	$1, %eax
	cltq
	imulq	%rdx, %rax
	subq	%rax, -16(%rbp)
	addl	$1, -20(%rbp)
.L4:
	movl	-32(%rbp), %eax
	cmpl	%eax, -20(%rbp)
	jl	.L6
	movq	-16(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movq	stdout(%rip), %rax
	movq	%rax, %rdi
	call	fflush@PLT
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L8
	call	__stack_chk_fail@PLT
.L8:
	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	"%d %d"
.LC2:
	.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	$32, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movq	$0, -16(%rbp)
	leaq	-32(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$1, -20(%rbp)
	jmp	.L2
.L3:
	movl	-32(%rbp), %eax
	subl	-20(%rbp), %eax
	addl	$2, %eax
	movslq	%eax, %rdx
	movl	-32(%rbp), %eax
	subl	-20(%rbp), %eax
	addl	$1, %eax
	cltq
	imulq	%rdx, %rax
	movq	%rax, %rdx
	shrq	$63, %rdx
	addq	%rdx, %rax
	sarq	%rax
	addq	%rax, -16(%rbp)
	addl	$1, -20(%rbp)
.L2:
	movl	-32(%rbp), %eax
	cmpl	%eax, -20(%rbp)
	jle	.L3
	movl	$1, -20(%rbp)
	jmp	.L4
.L6:
	leaq	-24(%rbp), %rdx
	leaq	-28(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-28(%rbp), %edx
	movl	-24(%rbp), %eax
	cmpl	%eax, %edx
	jle	.L5
	movl	-28(%rbp), %edx
	movl	-24(%rbp), %eax
	xorl	%edx, %eax
	movl	%eax, -28(%rbp)
	movl	-24(%rbp), %edx
	movl	-28(%rbp), %eax
	xorl	%edx, %eax
	movl	%eax, -24(%rbp)
	movl	-28(%rbp), %edx
	movl	-24(%rbp), %eax
	xorl	%edx, %eax
	movl	%eax, -28(%rbp)
.L5:
	movl	-28(%rbp), %eax
	movslq	%eax, %rdx
	movl	-32(%rbp), %eax
	movl	-24(%rbp), %ecx
	subl	%ecx, %eax
	addl	$1, %eax
	cltq
	imulq	%rdx, %rax
	subq	%rax, -16(%rbp)
	addl	$1, -20(%rbp)
.L4:
	movl	-32(%rbp), %eax
	cmpl	%eax, -20(%rbp)
	jl	.L6
	movq	-16(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movq	stdout(%rip), %rax
	movq	%rax, %rdi
	call	fflush@PLT
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L8
	call	__stack_chk_fail@PLT
.L8:
	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:
