Given the following C code and unoptimized assembly code, your task is to generate highly optimized x86-64 assembly code.
C Code:

```c
#pragma GCC optimize("Ofast")
#include<stdio.h>
int main(void)
{
    long n = 0;
    char c=getchar_unlocked();
    while(c<='9'&&c>='0') {n=(n<<1)+(n<<3)+c-'0'; c=getchar_unlocked();}
    long ans = n * (n + 1) / 2 * (n + 2) / 3;
    int u, v, i = n;
    ++n;
    while(--i)
    {
        u = v = 0;
        c=getchar_unlocked();
        while(c<='9'&&c>='0') {u=(u<<1)+(u<<3)+c-'0'; c=getchar_unlocked();}
        c=getchar_unlocked();
        while(c<='9'&&c>='0') {v=(v<<1)+(v<<3)+c-'0'; c=getchar_unlocked();}
        switch(u > v)
        {
            case 1: ans -= v * (n - u); break;
            default: ans -= u * (n - v);
        }
    }
    printf("%ld", ans);
    return 0;
}
```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%ld"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$8, %rsp
	.cfi_def_cfa_offset 64
	call	getchar_unlocked@PLT
	movsbq	%al, %rdx
	subl	$48, %eax
	cmpb	$9, %al
	ja	.L12
	xorl	%ebp, %ebp
	.p2align 4,,10
	.p2align 3
.L3:
	leaq	0(%rbp,%rbp,4), %rax
	leaq	(%rdx,%rax,2), %rbx
	call	getchar_unlocked@PLT
	leaq	-48(%rbx), %rbp
	movsbq	%al, %rdx
	subl	$48, %eax
	cmpb	$9, %al
	jbe	.L3
	movabsq	$6148914691236517206, %rdx
	leaq	-47(%rbx), %r14
	subq	$46, %rbx
	movq	%r14, %rax
	imulq	%rbp, %rax
	movq	%rax, %rcx
	shrq	$63, %rcx
	addq	%rax, %rcx
	sarq	%rcx
	imulq	%rbx, %rcx
	movq	%rcx, %rax
	sarq	$63, %rcx
	imulq	%rdx
	subq	%rcx, %rdx
	movq	%rdx, %r12
	subl	$1, %ebp
	je	.L4
	.p2align 4,,10
	.p2align 3
.L11:
	call	getchar_unlocked@PLT
	movsbl	%al, %edx
	subl	$48, %eax
	cmpb	$9, %al
	ja	.L13
	xorl	%ebx, %ebx
	.p2align 4,,10
	.p2align 3
.L6:
	leal	(%rbx,%rbx,4), %eax
	leal	-48(%rdx,%rax,2), %ebx
	call	getchar_unlocked@PLT
	movsbl	%al, %edx
	subl	$48, %eax
	cmpb	$9, %al
	jbe	.L6
	movslq	%ebx, %r13
.L5:
	call	getchar_unlocked@PLT
	movsbl	%al, %edx
	subl	$48, %eax
	cmpb	$9, %al
	ja	.L14
	xorl	%r15d, %r15d
	.p2align 4,,10
	.p2align 3
.L8:
	leal	(%r15,%r15,4), %eax
	leal	-48(%rdx,%rax,2), %r15d
	call	getchar_unlocked@PLT
	movsbl	%al, %edx
	subl	$48, %eax
	cmpb	$9, %al
	jbe	.L8
	movslq	%r15d, %rdx
.L7:
	movq	%r14, %rax
	cmpl	%r15d, %ebx
	jle	.L9
	subq	%r13, %rax
	imulq	%rdx, %rax
	subq	%rax, %r12
.L10:
	subl	$1, %ebp
	jne	.L11
.L4:
	movq	%r12, %rsi
	leaq	.LC0(%rip), %rdi
	xorl	%eax, %eax
	call	printf@PLT
	addq	$8, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 56
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L9:
	.cfi_restore_state
	subq	%rdx, %rax
	imulq	%r13, %rax
	subq	%rax, %r12
	jmp	.L10
	.p2align 4,,10
	.p2align 3
.L14:
	xorl	%edx, %edx
	xorl	%r15d, %r15d
	jmp	.L7
	.p2align 4,,10
	.p2align 3
.L13:
	xorl	%r13d, %r13d
	xorl	%ebx, %ebx
	jmp	.L5
.L12:
	movl	$1, %r14d
	orl	$-1, %ebp
	xorl	%r12d, %r12d
	jmp	.L11
	.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"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB23:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$8, %rsp
	.cfi_def_cfa_offset 64
	movq	stdin(%rip), %rdi
	movq	8(%rdi), %rdx
	movq	16(%rdi), %rcx
	cmpq	%rcx, %rdx
	jnb	.L40
	leaq	1(%rdx), %rax
	movq	%rax, 8(%rdi)
	movzbl	(%rdx), %edx
	movl	%edx, %esi
.L3:
	subl	$48, %esi
	cmpb	$9, %sil
	ja	.L27
	xorl	%ebx, %ebx
	jmp	.L8
	.p2align 4,,10
	.p2align 3
.L5:
	leaq	1(%rax), %rdx
	movq	%rdx, 8(%rdi)
	movzbl	(%rax), %edx
	leal	-48(%rdx), %eax
	cmpb	$9, %al
	ja	.L7
.L6:
	movq	8(%rdi), %rax
	movq	16(%rdi), %rcx
.L8:
	leaq	(%rbx,%rbx,4), %rsi
	movsbq	%dl, %rdx
	leaq	(%rdx,%rsi,2), %r12
	leaq	-48(%r12), %rbx
	cmpq	%rcx, %rax
	jb	.L5
	call	__uflow@PLT
	movl	%eax, %edx
	subl	$48, %eax
	cmpb	$9, %al
	ja	.L7
	movq	stdin(%rip), %rdi
	jmp	.L6
	.p2align 4,,10
	.p2align 3
.L7:
	movabsq	$6148914691236517206, %rdx
	leaq	-47(%r12), %rbp
	subq	$46, %r12
	movq	%rbp, %rax
	imulq	%rbx, %rax
	movq	%rax, %rcx
	shrq	$63, %rcx
	addq	%rax, %rcx
	sarq	%rcx
	imulq	%r12, %rcx
	movq	%rcx, %rax
	sarq	$63, %rcx
	imulq	%rdx
	subq	%rcx, %rdx
	movq	%rdx, %r12
	subl	$1, %ebx
	je	.L9
	.p2align 4,,10
	.p2align 3
.L37:
	movq	stdin(%rip), %rdi
.L26:
	movq	8(%rdi), %rdx
	movq	16(%rdi), %rsi
	cmpq	%rsi, %rdx
	jnb	.L41
	leaq	1(%rdx), %rax
	movq	%rax, 8(%rdi)
	movzbl	(%rdx), %edx
	movl	%edx, %ecx
.L11:
	subl	$48, %ecx
	cmpb	$9, %cl
	ja	.L28
	xorl	%r14d, %r14d
	jmp	.L16
	.p2align 4,,10
	.p2align 3
.L13:
	leaq	1(%rax), %rcx
	movq	%rcx, 8(%rdi)
	movzbl	(%rax), %edx
	leal	-48(%rdx), %eax
	cmpb	$9, %al
	ja	.L15
.L14:
	movq	%rcx, %rax
.L16:
	leal	(%r14,%r14,4), %ecx
	movsbl	%dl, %edx
	leal	-48(%rdx,%rcx,2), %r14d
	cmpq	%rsi, %rax
	jb	.L13
	call	__uflow@PLT
	movq	stdin(%rip), %rdi
	movl	%eax, %edx
	subl	$48, %eax
	movq	8(%rdi), %rcx
	movq	16(%rdi), %rsi
	cmpb	$9, %al
	jbe	.L14
	.p2align 4,,10
	.p2align 3
.L15:
	movslq	%r14d, %r15
	cmpq	%rsi, %rcx
	jnb	.L42
.L17:
	leaq	1(%rcx), %rax
	movq	%rax, 8(%rdi)
	movzbl	(%rcx), %ecx
	movl	%ecx, %eax
.L18:
	subl	$48, %eax
	cmpb	$9, %al
	ja	.L29
	xorl	%r13d, %r13d
.L38:
	movq	stdin(%rip), %rdi
	jmp	.L23
	.p2align 4,,10
	.p2align 3
.L20:
	leaq	1(%rax), %rdx
	movq	%rdx, 8(%rdi)
	movzbl	(%rax), %ecx
	leal	-48(%rcx), %eax
	cmpb	$9, %al
	ja	.L22
.L23:
	leal	0(%r13,%r13,4), %eax
	movsbl	%cl, %ecx
	leal	-48(%rcx,%rax,2), %r13d
	movq	8(%rdi), %rax
	cmpq	16(%rdi), %rax
	jb	.L20
	call	__uflow@PLT
	movl	%eax, %ecx
	subl	$48, %eax
	cmpb	$9, %al
	jbe	.L38
	.p2align 4,,10
	.p2align 3
.L22:
	movslq	%r13d, %rdx
.L19:
	movq	%rbp, %rax
	cmpl	%r13d, %r14d
	jle	.L24
	subq	%r15, %rax
	imulq	%rdx, %rax
	subq	%rax, %r12
.L25:
	subl	$1, %ebx
	jne	.L37
.L9:
	movq	%r12, %rdx
	leaq	.LC0(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	addq	$8, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 56
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L24:
	.cfi_restore_state
	subq	%rdx, %rax
	imulq	%r15, %rax
	subq	%rax, %r12
	jmp	.L25
	.p2align 4,,10
	.p2align 3
.L29:
	xorl	%edx, %edx
	xorl	%r13d, %r13d
	jmp	.L19
	.p2align 4,,10
	.p2align 3
.L28:
	movq	%rax, %rcx
	xorl	%r15d, %r15d
	xorl	%r14d, %r14d
	cmpq	%rsi, %rcx
	jb	.L17
	.p2align 4,,10
	.p2align 3
.L42:
	call	__uflow@PLT
	movl	%eax, %ecx
	jmp	.L18
	.p2align 4,,10
	.p2align 3
.L41:
	call	__uflow@PLT
	movq	stdin(%rip), %rdi
	movl	%eax, %edx
	movl	%eax, %ecx
	movq	16(%rdi), %rsi
	movq	8(%rdi), %rax
	jmp	.L11
.L27:
	movl	$1, %ebp
	orl	$-1, %ebx
	xorl	%r12d, %r12d
	jmp	.L26
.L40:
	call	__uflow@PLT
	movq	stdin(%rip), %rdi
	movl	%eax, %edx
	movl	%eax, %esi
	movq	16(%rdi), %rcx
	movq	8(%rdi), %rax
	jmp	.L3
	.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"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB23:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$8, %rsp
	.cfi_def_cfa_offset 64
	movq	stdin(%rip), %rdi
	movq	8(%rdi), %rdx
	movq	16(%rdi), %rcx
	cmpq	%rcx, %rdx
	jnb	.L40
	leaq	1(%rdx), %rax
	movq	%rax, 8(%rdi)
	movzbl	(%rdx), %edx
	movl	%edx, %esi
.L3:
	subl	$48, %esi
	cmpb	$9, %sil
	ja	.L27
	xorl	%ebx, %ebx
	jmp	.L8
	.p2align 4,,10
	.p2align 3
.L5:
	leaq	1(%rax), %rdx
	movq	%rdx, 8(%rdi)
	movzbl	(%rax), %edx
	leal	-48(%rdx), %eax
	cmpb	$9, %al
	ja	.L7
.L6:
	movq	8(%rdi), %rax
	movq	16(%rdi), %rcx
.L8:
	leaq	(%rbx,%rbx,4), %rsi
	movsbq	%dl, %rdx
	leaq	(%rdx,%rsi,2), %r12
	leaq	-48(%r12), %rbx
	cmpq	%rcx, %rax
	jb	.L5
	call	__uflow@PLT
	movl	%eax, %edx
	subl	$48, %eax
	cmpb	$9, %al
	ja	.L7
	movq	stdin(%rip), %rdi
	jmp	.L6
	.p2align 4,,10
	.p2align 3
.L7:
	movabsq	$6148914691236517206, %rdx
	leaq	-47(%r12), %rbp
	subq	$46, %r12
	movq	%rbp, %rax
	imulq	%rbx, %rax
	movq	%rax, %rcx
	shrq	$63, %rcx
	addq	%rax, %rcx
	sarq	%rcx
	imulq	%r12, %rcx
	movq	%rcx, %rax
	sarq	$63, %rcx
	imulq	%rdx
	subq	%rcx, %rdx
	movq	%rdx, %r12
	subl	$1, %ebx
	je	.L9
	.p2align 4,,10
	.p2align 3
.L37:
	movq	stdin(%rip), %rdi
.L26:
	movq	8(%rdi), %rdx
	movq	16(%rdi), %rsi
	cmpq	%rsi, %rdx
	jnb	.L41
	leaq	1(%rdx), %rax
	movq	%rax, 8(%rdi)
	movzbl	(%rdx), %edx
	movl	%edx, %ecx
.L11:
	subl	$48, %ecx
	cmpb	$9, %cl
	ja	.L28
	xorl	%r14d, %r14d
	jmp	.L16
	.p2align 4,,10
	.p2align 3
.L13:
	leaq	1(%rax), %rcx
	movq	%rcx, 8(%rdi)
	movzbl	(%rax), %edx
	leal	-48(%rdx), %eax
	cmpb	$9, %al
	ja	.L15
.L14:
	movq	%rcx, %rax
.L16:
	leal	(%r14,%r14,4), %ecx
	movsbl	%dl, %edx
	leal	-48(%rdx,%rcx,2), %r14d
	cmpq	%rsi, %rax
	jb	.L13
	call	__uflow@PLT
	movq	stdin(%rip), %rdi
	movl	%eax, %edx
	subl	$48, %eax
	movq	8(%rdi), %rcx
	movq	16(%rdi), %rsi
	cmpb	$9, %al
	jbe	.L14
	.p2align 4,,10
	.p2align 3
.L15:
	movslq	%r14d, %r15
	cmpq	%rsi, %rcx
	jnb	.L42
.L17:
	leaq	1(%rcx), %rax
	movq	%rax, 8(%rdi)
	movzbl	(%rcx), %ecx
	movl	%ecx, %eax
.L18:
	subl	$48, %eax
	cmpb	$9, %al
	ja	.L29
	xorl	%r13d, %r13d
.L38:
	movq	stdin(%rip), %rdi
	jmp	.L23
	.p2align 4,,10
	.p2align 3
.L20:
	leaq	1(%rax), %rdx
	movq	%rdx, 8(%rdi)
	movzbl	(%rax), %ecx
	leal	-48(%rcx), %eax
	cmpb	$9, %al
	ja	.L22
.L23:
	leal	0(%r13,%r13,4), %eax
	movsbl	%cl, %ecx
	leal	-48(%rcx,%rax,2), %r13d
	movq	8(%rdi), %rax
	cmpq	16(%rdi), %rax
	jb	.L20
	call	__uflow@PLT
	movl	%eax, %ecx
	subl	$48, %eax
	cmpb	$9, %al
	jbe	.L38
	.p2align 4,,10
	.p2align 3
.L22:
	movslq	%r13d, %rdx
.L19:
	movq	%rbp, %rax
	cmpl	%r13d, %r14d
	jle	.L24
	subq	%r15, %rax
	imulq	%rdx, %rax
	subq	%rax, %r12
.L25:
	subl	$1, %ebx
	jne	.L37
.L9:
	movq	%r12, %rdx
	leaq	.LC0(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	addq	$8, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 56
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L24:
	.cfi_restore_state
	subq	%rdx, %rax
	imulq	%r15, %rax
	subq	%rax, %r12
	jmp	.L25
	.p2align 4,,10
	.p2align 3
.L29:
	xorl	%edx, %edx
	xorl	%r13d, %r13d
	jmp	.L19
	.p2align 4,,10
	.p2align 3
.L28:
	movq	%rax, %rcx
	xorl	%r15d, %r15d
	xorl	%r14d, %r14d
	cmpq	%rsi, %rcx
	jb	.L17
	.p2align 4,,10
	.p2align 3
.L42:
	call	__uflow@PLT
	movl	%eax, %ecx
	jmp	.L18
	.p2align 4,,10
	.p2align 3
.L41:
	call	__uflow@PLT
	movq	stdin(%rip), %rdi
	movl	%eax, %edx
	movl	%eax, %ecx
	movq	16(%rdi), %rsi
	movq	8(%rdi), %rax
	jmp	.L11
.L27:
	movl	$1, %ebp
	orl	$-1, %ebx
	xorl	%r12d, %r12d
	jmp	.L26
.L40:
	call	__uflow@PLT
	movq	stdin(%rip), %rdi
	movl	%eax, %edx
	movl	%eax, %esi
	movq	16(%rdi), %rcx
	movq	8(%rdi), %rax
	jmp	.L3
	.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:

#pragma GCC optimize("Ofast")
#include<stdio.h>
int main(void)
{
    long n = 0;
    char c=getchar_unlocked();
    while(c<='9'&&c>='0') {n=(n<<1)+(n<<3)+c-'0'; c=getchar_unlocked();}
    long ans = n * (n + 1) / 2 * (n + 2) / 3;
    int u, v, i = n;
    ++n;
    while(--i)
    {
        u = v = 0;
        c=getchar_unlocked();
        while(c<='9'&&c>='0') {u=(u<<1)+(u<<3)+c-'0'; c=getchar_unlocked();}
        c=getchar_unlocked();
        while(c<='9'&&c>='0') {v=(v<<1)+(v<<3)+c-'0'; c=getchar_unlocked();}
        switch(u > v)
        {
            case 1: ans -= v * (n - u); break;
            default: ans -= u * (n - v);
        }
    }
    printf("%ld", ans);
    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 4 118 4 10 146 132
Given the following C code and unoptimized assembly code, your task is to generate highly optimized x86-64 assembly code.
C Code:

```c
#pragma GCC optimize("Ofast")
#include<stdio.h>
int main(void)
{
    long n = 0;
    char c=getchar_unlocked();
    while(c<='9'&&c>='0') {n=(n<<1)+(n<<3)+c-'0'; c=getchar_unlocked();}
    long ans = n * (n + 1) / 2 * (n + 2) / 3;
    int u, v, i = n;
    ++n;
    while(--i)
    {
        u = v = 0;
        c=getchar_unlocked();
        while(c<='9'&&c>='0') {u=(u<<1)+(u<<3)+c-'0'; c=getchar_unlocked();}
        c=getchar_unlocked();
        while(c<='9'&&c>='0') {v=(v<<1)+(v<<3)+c-'0'; c=getchar_unlocked();}
        switch(u > v)
        {
            case 1: ans -= v * (n - u); break;
            default: ans -= u * (n - v);
        }
    }
    printf("%ld", ans);
    return 0;
}
```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%ld"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$8, %rsp
	.cfi_def_cfa_offset 64
	call	getchar_unlocked@PLT
	movsbq	%al, %rdx
	subl	$48, %eax
	cmpb	$9, %al
	ja	.L12
	xorl	%ebp, %ebp
	.p2align 4,,10
	.p2align 3
.L3:
	leaq	0(%rbp,%rbp,4), %rax
	leaq	(%rdx,%rax,2), %rbx
	call	getchar_unlocked@PLT
	leaq	-48(%rbx), %rbp
	movsbq	%al, %rdx
	subl	$48, %eax
	cmpb	$9, %al
	jbe	.L3
	movabsq	$6148914691236517206, %rdx
	leaq	-47(%rbx), %r14
	subq	$46, %rbx
	movq	%r14, %rax
	imulq	%rbp, %rax
	movq	%rax, %rcx
	shrq	$63, %rcx
	addq	%rax, %rcx
	sarq	%rcx
	imulq	%rbx, %rcx
	movq	%rcx, %rax
	sarq	$63, %rcx
	imulq	%rdx
	subq	%rcx, %rdx
	movq	%rdx, %r12
	subl	$1, %ebp
	je	.L4
	.p2align 4,,10
	.p2align 3
.L11:
	call	getchar_unlocked@PLT
	movsbl	%al, %edx
	subl	$48, %eax
	cmpb	$9, %al
	ja	.L13
	xorl	%ebx, %ebx
	.p2align 4,,10
	.p2align 3
.L6:
	leal	(%rbx,%rbx,4), %eax
	leal	-48(%rdx,%rax,2), %ebx
	call	getchar_unlocked@PLT
	movsbl	%al, %edx
	subl	$48, %eax
	cmpb	$9, %al
	jbe	.L6
	movslq	%ebx, %r13
.L5:
	call	getchar_unlocked@PLT
	movsbl	%al, %edx
	subl	$48, %eax
	cmpb	$9, %al
	ja	.L14
	xorl	%r15d, %r15d
	.p2align 4,,10
	.p2align 3
.L8:
	leal	(%r15,%r15,4), %eax
	leal	-48(%rdx,%rax,2), %r15d
	call	getchar_unlocked@PLT
	movsbl	%al, %edx
	subl	$48, %eax
	cmpb	$9, %al
	jbe	.L8
	movslq	%r15d, %rdx
.L7:
	movq	%r14, %rax
	cmpl	%r15d, %ebx
	jle	.L9
	subq	%r13, %rax
	imulq	%rdx, %rax
	subq	%rax, %r12
.L10:
	subl	$1, %ebp
	jne	.L11
.L4:
	movq	%r12, %rsi
	leaq	.LC0(%rip), %rdi
	xorl	%eax, %eax
	call	printf@PLT
	addq	$8, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 56
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L9:
	.cfi_restore_state
	subq	%rdx, %rax
	imulq	%r13, %rax
	subq	%rax, %r12
	jmp	.L10
	.p2align 4,,10
	.p2align 3
.L14:
	xorl	%edx, %edx
	xorl	%r15d, %r15d
	jmp	.L7
	.p2align 4,,10
	.p2align 3
.L13:
	xorl	%r13d, %r13d
	xorl	%ebx, %ebx
	jmp	.L5
.L12:
	movl	$1, %r14d
	orl	$-1, %ebp
	xorl	%r12d, %r12d
	jmp	.L11
	.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.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%ld"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$8, %rsp
	.cfi_def_cfa_offset 64
	call	getchar_unlocked@PLT
	movsbq	%al, %rdx
	subl	$48, %eax
	cmpb	$9, %al
	ja	.L12
	xorl	%ebp, %ebp
	.p2align 4,,10
	.p2align 3
.L3:
	leaq	0(%rbp,%rbp,4), %rax
	leaq	(%rdx,%rax,2), %rbx
	call	getchar_unlocked@PLT
	leaq	-48(%rbx), %rbp
	movsbq	%al, %rdx
	subl	$48, %eax
	cmpb	$9, %al
	jbe	.L3
	movabsq	$6148914691236517206, %rdx
	leaq	-47(%rbx), %r14
	subq	$46, %rbx
	movq	%r14, %rax
	imulq	%rbp, %rax
	movq	%rax, %rcx
	shrq	$63, %rcx
	addq	%rax, %rcx
	sarq	%rcx
	imulq	%rbx, %rcx
	movq	%rcx, %rax
	sarq	$63, %rcx
	imulq	%rdx
	subq	%rcx, %rdx
	movq	%rdx, %r12
	subl	$1, %ebp
	je	.L4
	.p2align 4,,10
	.p2align 3
.L11:
	call	getchar_unlocked@PLT
	movsbl	%al, %edx
	subl	$48, %eax
	cmpb	$9, %al
	ja	.L13
	xorl	%ebx, %ebx
	.p2align 4,,10
	.p2align 3
.L6:
	leal	(%rbx,%rbx,4), %eax
	leal	-48(%rdx,%rax,2), %ebx
	call	getchar_unlocked@PLT
	movsbl	%al, %edx
	subl	$48, %eax
	cmpb	$9, %al
	jbe	.L6
	movslq	%ebx, %r13
.L5:
	call	getchar_unlocked@PLT
	movsbl	%al, %edx
	subl	$48, %eax
	cmpb	$9, %al
	ja	.L14
	xorl	%r15d, %r15d
	.p2align 4,,10
	.p2align 3
.L8:
	leal	(%r15,%r15,4), %eax
	leal	-48(%rdx,%rax,2), %r15d
	call	getchar_unlocked@PLT
	movsbl	%al, %edx
	subl	$48, %eax
	cmpb	$9, %al
	jbe	.L8
	movslq	%r15d, %rdx
.L7:
	movq	%r14, %rax
	cmpl	%r15d, %ebx
	jle	.L9
	subq	%r13, %rax
	imulq	%rdx, %rax
	subq	%rax, %r12
.L10:
	subl	$1, %ebp
	jne	.L11
.L4:
	movq	%r12, %rsi
	leaq	.LC0(%rip), %rdi
	xorl	%eax, %eax
	call	printf@PLT
	addq	$8, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 56
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L9:
	.cfi_restore_state
	subq	%rdx, %rax
	imulq	%r13, %rax
	subq	%rax, %r12
	jmp	.L10
	.p2align 4,,10
	.p2align 3
.L14:
	xorl	%edx, %edx
	xorl	%r15d, %r15d
	jmp	.L7
	.p2align 4,,10
	.p2align 3
.L13:
	xorl	%r13d, %r13d
	xorl	%ebx, %ebx
	jmp	.L5
.L12:
	movl	$1, %r14d
	orl	$-1, %ebp
	xorl	%r12d, %r12d
	jmp	.L11
	.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:
