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

int main(int argc, char* argv[]){
        char tmp[1024+1]={0};
        char *buf=NULL;
        char* p=NULL;
        int N=0;
        int *A=NULL;
        int *C=NULL;

        buf = (char*)calloc(200000+1, 7);
        if(fgets(buf, sizeof(buf)-1, stdin)==NULL){
                return 1;
        }
        N = atoi(buf);

        A = (int*)calloc(N+1, sizeof(int));
        C = (int*)calloc(N+2, sizeof(int));
        for(int i=0; i<N+1; i++){ C[i]=0; }

        memset(buf, 0, N*7+1);
        while(fgets(tmp, sizeof(tmp)-1, stdin)!=NULL){
                strcat(buf, tmp);
                memset(tmp, 0 , sizeof(tmp));
        }

        p = strtok(buf, " ");
        A[0] = atoi(p);
        C[A[0]]++;
        for(int i=1; i<N; i++){
                p = strtok(NULL, " ");
                A[i] = atoi(p);
                C[A[i]]++;
        }
        long long total=0;
        for(int i=1; i<N+1; i++){
                long long a = (long long)C[i];
                total += a*(a-1)/2;
        }
        for(int i=0; i<N; i++){
                long long v = (long long)C[A[i]];
                long long d = 0;
                if(v>1) {
                        d = v*(v-1)/2 - (v-1)*(v-2)/2;
                }
                long long ans = total - d;
                printf("%lld\n", ans);
        }
        return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	" "
.LC1:
	.string	"%lld\n"
	.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
	pushq	%rbx
	subq	$1160, %rsp
	.cfi_offset 3, -24
	movl	%edi, -1156(%rbp)
	movq	%rsi, -1168(%rbp)
	movq	%fs:40, %rax
	movq	%rax, -24(%rbp)
	xorl	%eax, %eax
	movq	$0, -1056(%rbp)
	movq	$0, -1048(%rbp)
	leaq	-1040(%rbp), %rdx
	movl	$0, %eax
	movl	$126, %ecx
	movq	%rdx, %rdi
	rep stosq
	movq	%rdi, %rdx
	movb	%al, (%rdx)
	addq	$1, %rdx
	movq	$0, -1112(%rbp)
	movq	$0, -1104(%rbp)
	movl	$0, -1132(%rbp)
	movq	$0, -1096(%rbp)
	movq	$0, -1088(%rbp)
	movl	$7, %esi
	movl	$200001, %edi
	call	calloc@PLT
	movq	%rax, -1112(%rbp)
	movq	stdin(%rip), %rdx
	movq	-1112(%rbp), %rax
	movl	$7, %esi
	movq	%rax, %rdi
	call	fgets@PLT
	testq	%rax, %rax
	jne	.L2
	movl	$1, %eax
	jmp	.L15
.L2:
	movq	-1112(%rbp), %rax
	movq	%rax, %rdi
	call	atoi@PLT
	movl	%eax, -1132(%rbp)
	movl	-1132(%rbp), %eax
	addl	$1, %eax
	cltq
	movl	$4, %esi
	movq	%rax, %rdi
	call	calloc@PLT
	movq	%rax, -1096(%rbp)
	movl	-1132(%rbp), %eax
	addl	$2, %eax
	cltq
	movl	$4, %esi
	movq	%rax, %rdi
	call	calloc@PLT
	movq	%rax, -1088(%rbp)
	movl	$0, -1148(%rbp)
	jmp	.L4
.L5:
	movl	-1148(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-1088(%rbp), %rax
	addq	%rdx, %rax
	movl	$0, (%rax)
	addl	$1, -1148(%rbp)
.L4:
	movl	-1132(%rbp), %eax
	cmpl	-1148(%rbp), %eax
	jge	.L5
	movl	-1132(%rbp), %edx
	movl	%edx, %eax
	sall	$3, %eax
	subl	%edx, %eax
	addl	$1, %eax
	movslq	%eax, %rdx
	movq	-1112(%rbp), %rax
	movl	$0, %esi
	movq	%rax, %rdi
	call	memset@PLT
	jmp	.L6
.L7:
	leaq	-1056(%rbp), %rdx
	movq	-1112(%rbp), %rax
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	strcat@PLT
	leaq	-1056(%rbp), %rax
	movl	$1025, %edx
	movl	$0, %esi
	movq	%rax, %rdi
	call	memset@PLT
.L6:
	movq	stdin(%rip), %rdx
	leaq	-1056(%rbp), %rax
	movl	$1024, %esi
	movq	%rax, %rdi
	call	fgets@PLT
	testq	%rax, %rax
	jne	.L7
	movq	-1112(%rbp), %rax
	leaq	.LC0(%rip), %rdx
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	strtok@PLT
	movq	%rax, -1104(%rbp)
	movq	-1104(%rbp), %rax
	movq	%rax, %rdi
	call	atoi@PLT
	movq	-1096(%rbp), %rdx
	movl	%eax, (%rdx)
	movq	-1096(%rbp), %rax
	movl	(%rax), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-1088(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %edx
	addl	$1, %edx
	movl	%edx, (%rax)
	movl	$1, -1144(%rbp)
	jmp	.L8
.L9:
	leaq	.LC0(%rip), %rax
	movq	%rax, %rsi
	movl	$0, %edi
	call	strtok@PLT
	movq	%rax, -1104(%rbp)
	movl	-1144(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-1096(%rbp), %rax
	leaq	(%rdx,%rax), %rbx
	movq	-1104(%rbp), %rax
	movq	%rax, %rdi
	call	atoi@PLT
	movl	%eax, (%rbx)
	movl	-1144(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-1096(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-1088(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %edx
	addl	$1, %edx
	movl	%edx, (%rax)
	addl	$1, -1144(%rbp)
.L8:
	movl	-1144(%rbp), %eax
	cmpl	-1132(%rbp), %eax
	jl	.L9
	movq	$0, -1128(%rbp)
	movl	$1, -1140(%rbp)
	jmp	.L10
.L11:
	movl	-1140(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-1088(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	cltq
	movq	%rax, -1064(%rbp)
	movq	-1064(%rbp), %rax
	subq	$1, %rax
	imulq	-1064(%rbp), %rax
	movq	%rax, %rdx
	shrq	$63, %rdx
	addq	%rdx, %rax
	sarq	%rax
	addq	%rax, -1128(%rbp)
	addl	$1, -1140(%rbp)
.L10:
	movl	-1132(%rbp), %eax
	cmpl	-1140(%rbp), %eax
	jge	.L11
	movl	$0, -1136(%rbp)
	jmp	.L12
.L14:
	movl	-1136(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-1096(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-1088(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	cltq
	movq	%rax, -1080(%rbp)
	movq	$0, -1120(%rbp)
	cmpq	$1, -1080(%rbp)
	jle	.L13
	movq	-1080(%rbp), %rax
	subq	$1, %rax
	imulq	-1080(%rbp), %rax
	movq	%rax, %rdx
	shrq	$63, %rdx
	addq	%rdx, %rax
	sarq	%rax
	movq	%rax, %rcx
	movq	-1080(%rbp), %rax
	leaq	-1(%rax), %rdx
	movq	-1080(%rbp), %rax
	subq	$2, %rax
	imulq	%rdx, %rax
	movq	%rax, %rdx
	shrq	$63, %rdx
	addq	%rdx, %rax
	sarq	%rax
	negq	%rax
	addq	%rcx, %rax
	movq	%rax, -1120(%rbp)
.L13:
	movq	-1128(%rbp), %rax
	subq	-1120(%rbp), %rax
	movq	%rax, -1072(%rbp)
	movq	-1072(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	addl	$1, -1136(%rbp)
.L12:
	movl	-1136(%rbp), %eax
	cmpl	-1132(%rbp), %eax
	jl	.L14
	movl	$0, %eax
.L15:
	movq	-24(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L16
	call	__stack_chk_fail@PLT
.L16:
	movq	-8(%rbp), %rbx
	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	" "
.LC1:
	.string	"%lld\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB51:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	movl	$126, %ecx
	pxor	%xmm0, %xmm0
	movl	$7, %esi
	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	$1064, %rsp
	.cfi_def_cfa_offset 1120
	movq	%fs:40, %rax
	movq	%rax, 1048(%rsp)
	xorl	%eax, %eax
	leaq	32(%rsp), %rdi
	movaps	%xmm0, 16(%rsp)
	rep stosq
	movb	$0, (%rdi)
	movl	$200001, %edi
	call	calloc@PLT
	movq	stdin(%rip), %rdx
	movl	$7, %esi
	movq	%rax, %rdi
	movq	%rax, %r14
	call	fgets@PLT
	movq	%rax, %r8
	movl	$1, %eax
	testq	%r8, %r8
	je	.L1
	movl	$10, %edx
	xorl	%esi, %esi
	movq	%r14, %rdi
	xorl	%r13d, %r13d
	call	strtol@PLT
	movl	$4, %esi
	leal	1(%rax), %edi
	movq	%rax, %r15
	movq	%rax, 8(%rsp)
	movl	%eax, %ebp
	movslq	%edi, %rdi
	call	calloc@PLT
	leal	2(%r15), %edi
	movl	$4, %esi
	movslq	%edi, %rdi
	movq	%rax, %r12
	call	calloc@PLT
	movl	$1400007, %ecx
	xorl	%esi, %esi
	movq	%r14, %rdi
	leal	0(,%r15,8), %edx
	movq	%rax, %rbx
	subl	%r15d, %edx
	leaq	16(%rsp), %r15
	addl	$1, %edx
	movslq	%edx, %rdx
	call	__memset_chk@PLT
	jmp	.L3
	.p2align 4,,10
	.p2align 3
.L4:
	movq	%r14, %rdi
	movl	$1400007, %edx
	movq	%r15, %rsi
	call	__strcat_chk@PLT
	movl	$128, %ecx
	movq	%r15, %rdi
	movq	%r13, %rax
	rep stosq
	movb	$0, (%rdi)
.L3:
	movq	stdin(%rip), %rdx
	movl	$1024, %esi
	movq	%r15, %rdi
	call	fgets@PLT
	testq	%rax, %rax
	jne	.L4
	leaq	.LC0(%rip), %r13
	movq	%r14, %rdi
	movq	%r13, %rsi
	call	strtok@PLT
	movl	$10, %edx
	xorl	%esi, %esi
	movq	%rax, %rdi
	call	strtol@PLT
	movl	%eax, (%r12)
	cltq
	addl	$1, (%rbx,%rax,4)
	movq	8(%rsp), %rax
	cmpl	$1, %eax
	jle	.L5
	subl	$2, %eax
	leaq	4(%r12), %r15
	leaq	8(%r12,%rax,4), %r14
	.p2align 4,,10
	.p2align 3
.L6:
	movq	%r13, %rsi
	xorl	%edi, %edi
	addq	$4, %r15
	call	strtok@PLT
	movl	$10, %edx
	xorl	%esi, %esi
	movq	%rax, %rdi
	call	strtol@PLT
	movl	%eax, -4(%r15)
	cltq
	addl	$1, (%rbx,%rax,4)
	cmpq	%r14, %r15
	jne	.L6
	movl	$1, %ecx
	xorl	%r14d, %r14d
	.p2align 4,,10
	.p2align 3
.L7:
	movslq	(%rbx,%rcx,4), %rax
	addq	$1, %rcx
	leaq	-1(%rax), %rdx
	imulq	%rax, %rdx
	movq	%rdx, %rax
	shrq	$63, %rax
	addq	%rdx, %rax
	sarq	%rax
	addq	%rax, %r14
	cmpl	%ecx, %ebp
	jge	.L7
.L13:
	xorl	%r15d, %r15d
	leaq	.LC1(%rip), %r13
	.p2align 4,,10
	.p2align 3
.L12:
	movslq	(%r12,%r15,4), %rax
	movq	%r14, %rdx
	movslq	(%rbx,%rax,4), %rax
	cmpq	$1, %rax
	jle	.L22
	leaq	-1(%rax), %rdx
	imulq	%rdx, %rax
	addq	%rdx, %rdx
	movq	%rax, %rcx
	sarq	%rax
	subq	%rdx, %rcx
	movq	%rcx, %rdx
	shrq	$63, %rdx
	addq	%rcx, %rdx
	sarq	%rdx
	subq	%rdx, %rax
	movq	%r14, %rdx
	subq	%rax, %rdx
.L22:
	movq	%r13, %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	addq	$1, %r15
	call	__printf_chk@PLT
	cmpl	%r15d, %ebp
	jg	.L12
.L11:
	xorl	%eax, %eax
.L1:
	movq	1048(%rsp), %rdx
	subq	%fs:40, %rdx
	jne	.L24
	addq	$1064, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 56
	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
.L5:
	.cfi_restore_state
	jne	.L11
	movslq	4(%rbx), %rdx
	movl	$2, %ecx
	leaq	-1(%rdx), %rax
	imulq	%rdx, %rax
	cqto
	idivq	%rcx
	movq	%rax, %r14
	jmp	.L13
.L24:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE51:
	.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	" "
.LC1:
	.string	"%lld\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB51:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	movl	$126, %ecx
	pxor	%xmm0, %xmm0
	movl	$7, %esi
	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	$1064, %rsp
	.cfi_def_cfa_offset 1120
	movq	%fs:40, %rax
	movq	%rax, 1048(%rsp)
	xorl	%eax, %eax
	leaq	32(%rsp), %rdi
	movaps	%xmm0, 16(%rsp)
	rep stosq
	movb	$0, (%rdi)
	movl	$200001, %edi
	call	calloc@PLT
	movq	stdin(%rip), %rdx
	movl	$7, %esi
	movq	%rax, %rdi
	movq	%rax, %r14
	call	fgets@PLT
	movq	%rax, %r8
	movl	$1, %eax
	testq	%r8, %r8
	je	.L1
	movl	$10, %edx
	xorl	%esi, %esi
	movq	%r14, %rdi
	xorl	%r13d, %r13d
	call	strtol@PLT
	movl	$4, %esi
	leal	1(%rax), %edi
	movq	%rax, %r15
	movq	%rax, 8(%rsp)
	movl	%eax, %ebp
	movslq	%edi, %rdi
	call	calloc@PLT
	leal	2(%r15), %edi
	movl	$4, %esi
	movslq	%edi, %rdi
	movq	%rax, %r12
	call	calloc@PLT
	movl	$1400007, %ecx
	xorl	%esi, %esi
	movq	%r14, %rdi
	leal	0(,%r15,8), %edx
	movq	%rax, %rbx
	subl	%r15d, %edx
	leaq	16(%rsp), %r15
	addl	$1, %edx
	movslq	%edx, %rdx
	call	__memset_chk@PLT
	jmp	.L3
	.p2align 4,,10
	.p2align 3
.L4:
	movq	%r14, %rdi
	movl	$1400007, %edx
	movq	%r15, %rsi
	call	__strcat_chk@PLT
	movl	$128, %ecx
	movq	%r15, %rdi
	movq	%r13, %rax
	rep stosq
	movb	$0, (%rdi)
.L3:
	movq	stdin(%rip), %rdx
	movl	$1024, %esi
	movq	%r15, %rdi
	call	fgets@PLT
	testq	%rax, %rax
	jne	.L4
	leaq	.LC0(%rip), %r13
	movq	%r14, %rdi
	movq	%r13, %rsi
	call	strtok@PLT
	movl	$10, %edx
	xorl	%esi, %esi
	movq	%rax, %rdi
	call	strtol@PLT
	movl	%eax, (%r12)
	cltq
	addl	$1, (%rbx,%rax,4)
	movq	8(%rsp), %rax
	cmpl	$1, %eax
	jle	.L5
	subl	$2, %eax
	leaq	4(%r12), %r15
	leaq	8(%r12,%rax,4), %r14
	.p2align 4,,10
	.p2align 3
.L6:
	movq	%r13, %rsi
	xorl	%edi, %edi
	addq	$4, %r15
	call	strtok@PLT
	movl	$10, %edx
	xorl	%esi, %esi
	movq	%rax, %rdi
	call	strtol@PLT
	movl	%eax, -4(%r15)
	cltq
	addl	$1, (%rbx,%rax,4)
	cmpq	%r14, %r15
	jne	.L6
	movl	$1, %ecx
	xorl	%r14d, %r14d
	.p2align 4,,10
	.p2align 3
.L7:
	movslq	(%rbx,%rcx,4), %rax
	addq	$1, %rcx
	leaq	-1(%rax), %rdx
	imulq	%rax, %rdx
	movq	%rdx, %rax
	shrq	$63, %rax
	addq	%rdx, %rax
	sarq	%rax
	addq	%rax, %r14
	cmpl	%ecx, %ebp
	jge	.L7
.L13:
	xorl	%r15d, %r15d
	leaq	.LC1(%rip), %r13
	.p2align 4,,10
	.p2align 3
.L12:
	movslq	(%r12,%r15,4), %rax
	movq	%r14, %rdx
	movslq	(%rbx,%rax,4), %rax
	cmpq	$1, %rax
	jle	.L22
	leaq	-1(%rax), %rdx
	imulq	%rdx, %rax
	addq	%rdx, %rdx
	movq	%rax, %rcx
	sarq	%rax
	subq	%rdx, %rcx
	movq	%rcx, %rdx
	shrq	$63, %rdx
	addq	%rcx, %rdx
	sarq	%rdx
	subq	%rdx, %rax
	movq	%r14, %rdx
	subq	%rax, %rdx
.L22:
	movq	%r13, %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	addq	$1, %r15
	call	__printf_chk@PLT
	cmpl	%r15d, %ebp
	jg	.L12
.L11:
	xorl	%eax, %eax
.L1:
	movq	1048(%rsp), %rdx
	subq	%fs:40, %rdx
	jne	.L24
	addq	$1064, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 56
	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
.L5:
	.cfi_restore_state
	jne	.L11
	movslq	4(%rbx), %rdx
	movl	$2, %ecx
	leaq	-1(%rdx), %rax
	imulq	%rdx, %rax
	cqto
	idivq	%rcx
	movq	%rax, %r14
	jmp	.L13
.L24:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE51:
	.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>
#include <string.h>

int main(int argc, char* argv[]){
        char tmp[1024+1]={0};
        char *buf=NULL;
        char* p=NULL;
        int N=0;
        int *A=NULL;
        int *C=NULL;

        buf = (char*)calloc(200000+1, 7);
        if(fgets(buf, sizeof(buf)-1, stdin)==NULL){
                return 1;
        }
        N = atoi(buf);

        A = (int*)calloc(N+1, sizeof(int));
        C = (int*)calloc(N+2, sizeof(int));
        for(int i=0; i<N+1; i++){ C[i]=0; }

        memset(buf, 0, N*7+1);
        while(fgets(tmp, sizeof(tmp)-1, stdin)!=NULL){
                strcat(buf, tmp);
                memset(tmp, 0 , sizeof(tmp));
        }

        p = strtok(buf, " ");
        A[0] = atoi(p);
        C[A[0]]++;
        for(int i=1; i<N; i++){
                p = strtok(NULL, " ");
                A[i] = atoi(p);
                C[A[i]]++;
        }
        long long total=0;
        for(int i=1; i<N+1; i++){
                long long a = (long long)C[i];
                total += a*(a-1)/2;
        }
        for(int i=0; i<N; i++){
                long long v = (long long)C[A[i]];
                long long d = 0;
                if(v>1) {
                        d = v*(v-1)/2 - (v-1)*(v-2)/2;
                }
                long long ans = total - d;
                printf("%lld\n", ans);
        }
        return 0;
}
8
1 2 1 6 2 1 4 1
 5
0 1 2 1 2
 4
2 2 3 4
 5
3 3 2 3 3
 8
1 3 1 6 2 1 4 1
 5
0 1 2 1 0
 5
0 3 2 3 3
 8
1 3 1 6 2 0 4 1
 8
1 2 1 6 2 0 4 1
 8
1 1 1 6 2 0 4 1

4
6
4
7
6
4
7
4
 2
1
1
1
1
 0
0
1
1
 3
3
6
3
3
 3
6
3
6
6
3
6
3
 0
0
1
0
0
 3
1
3
1
1
 1
3
1
3
3
3
3
1
 2
3
2
4
3
4
4
2
 3
3
3
6
6
6
6
3

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

int main(int argc, char* argv[]){
        char tmp[1024+1]={0};
        char *buf=NULL;
        char* p=NULL;
        int N=0;
        int *A=NULL;
        int *C=NULL;

        buf = (char*)calloc(200000+1, 7);
        if(fgets(buf, sizeof(buf)-1, stdin)==NULL){
                return 1;
        }
        N = atoi(buf);

        A = (int*)calloc(N+1, sizeof(int));
        C = (int*)calloc(N+2, sizeof(int));
        for(int i=0; i<N+1; i++){ C[i]=0; }

        memset(buf, 0, N*7+1);
        while(fgets(tmp, sizeof(tmp)-1, stdin)!=NULL){
                strcat(buf, tmp);
                memset(tmp, 0 , sizeof(tmp));
        }

        p = strtok(buf, " ");
        A[0] = atoi(p);
        C[A[0]]++;
        for(int i=1; i<N; i++){
                p = strtok(NULL, " ");
                A[i] = atoi(p);
                C[A[i]]++;
        }
        long long total=0;
        for(int i=1; i<N+1; i++){
                long long a = (long long)C[i];
                total += a*(a-1)/2;
        }
        for(int i=0; i<N; i++){
                long long v = (long long)C[A[i]];
                long long d = 0;
                if(v>1) {
                        d = v*(v-1)/2 - (v-1)*(v-2)/2;
                }
                long long ans = total - d;
                printf("%lld\n", ans);
        }
        return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	" "
.LC1:
	.string	"%lld\n"
	.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
	pushq	%rbx
	subq	$1160, %rsp
	.cfi_offset 3, -24
	movl	%edi, -1156(%rbp)
	movq	%rsi, -1168(%rbp)
	movq	%fs:40, %rax
	movq	%rax, -24(%rbp)
	xorl	%eax, %eax
	movq	$0, -1056(%rbp)
	movq	$0, -1048(%rbp)
	leaq	-1040(%rbp), %rdx
	movl	$0, %eax
	movl	$126, %ecx
	movq	%rdx, %rdi
	rep stosq
	movq	%rdi, %rdx
	movb	%al, (%rdx)
	addq	$1, %rdx
	movq	$0, -1112(%rbp)
	movq	$0, -1104(%rbp)
	movl	$0, -1132(%rbp)
	movq	$0, -1096(%rbp)
	movq	$0, -1088(%rbp)
	movl	$7, %esi
	movl	$200001, %edi
	call	calloc@PLT
	movq	%rax, -1112(%rbp)
	movq	stdin(%rip), %rdx
	movq	-1112(%rbp), %rax
	movl	$7, %esi
	movq	%rax, %rdi
	call	fgets@PLT
	testq	%rax, %rax
	jne	.L2
	movl	$1, %eax
	jmp	.L15
.L2:
	movq	-1112(%rbp), %rax
	movq	%rax, %rdi
	call	atoi@PLT
	movl	%eax, -1132(%rbp)
	movl	-1132(%rbp), %eax
	addl	$1, %eax
	cltq
	movl	$4, %esi
	movq	%rax, %rdi
	call	calloc@PLT
	movq	%rax, -1096(%rbp)
	movl	-1132(%rbp), %eax
	addl	$2, %eax
	cltq
	movl	$4, %esi
	movq	%rax, %rdi
	call	calloc@PLT
	movq	%rax, -1088(%rbp)
	movl	$0, -1148(%rbp)
	jmp	.L4
.L5:
	movl	-1148(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-1088(%rbp), %rax
	addq	%rdx, %rax
	movl	$0, (%rax)
	addl	$1, -1148(%rbp)
.L4:
	movl	-1132(%rbp), %eax
	cmpl	-1148(%rbp), %eax
	jge	.L5
	movl	-1132(%rbp), %edx
	movl	%edx, %eax
	sall	$3, %eax
	subl	%edx, %eax
	addl	$1, %eax
	movslq	%eax, %rdx
	movq	-1112(%rbp), %rax
	movl	$0, %esi
	movq	%rax, %rdi
	call	memset@PLT
	jmp	.L6
.L7:
	leaq	-1056(%rbp), %rdx
	movq	-1112(%rbp), %rax
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	strcat@PLT
	leaq	-1056(%rbp), %rax
	movl	$1025, %edx
	movl	$0, %esi
	movq	%rax, %rdi
	call	memset@PLT
.L6:
	movq	stdin(%rip), %rdx
	leaq	-1056(%rbp), %rax
	movl	$1024, %esi
	movq	%rax, %rdi
	call	fgets@PLT
	testq	%rax, %rax
	jne	.L7
	movq	-1112(%rbp), %rax
	leaq	.LC0(%rip), %rdx
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	strtok@PLT
	movq	%rax, -1104(%rbp)
	movq	-1104(%rbp), %rax
	movq	%rax, %rdi
	call	atoi@PLT
	movq	-1096(%rbp), %rdx
	movl	%eax, (%rdx)
	movq	-1096(%rbp), %rax
	movl	(%rax), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-1088(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %edx
	addl	$1, %edx
	movl	%edx, (%rax)
	movl	$1, -1144(%rbp)
	jmp	.L8
.L9:
	leaq	.LC0(%rip), %rax
	movq	%rax, %rsi
	movl	$0, %edi
	call	strtok@PLT
	movq	%rax, -1104(%rbp)
	movl	-1144(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-1096(%rbp), %rax
	leaq	(%rdx,%rax), %rbx
	movq	-1104(%rbp), %rax
	movq	%rax, %rdi
	call	atoi@PLT
	movl	%eax, (%rbx)
	movl	-1144(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-1096(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-1088(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %edx
	addl	$1, %edx
	movl	%edx, (%rax)
	addl	$1, -1144(%rbp)
.L8:
	movl	-1144(%rbp), %eax
	cmpl	-1132(%rbp), %eax
	jl	.L9
	movq	$0, -1128(%rbp)
	movl	$1, -1140(%rbp)
	jmp	.L10
.L11:
	movl	-1140(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-1088(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	cltq
	movq	%rax, -1064(%rbp)
	movq	-1064(%rbp), %rax
	subq	$1, %rax
	imulq	-1064(%rbp), %rax
	movq	%rax, %rdx
	shrq	$63, %rdx
	addq	%rdx, %rax
	sarq	%rax
	addq	%rax, -1128(%rbp)
	addl	$1, -1140(%rbp)
.L10:
	movl	-1132(%rbp), %eax
	cmpl	-1140(%rbp), %eax
	jge	.L11
	movl	$0, -1136(%rbp)
	jmp	.L12
.L14:
	movl	-1136(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-1096(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-1088(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	cltq
	movq	%rax, -1080(%rbp)
	movq	$0, -1120(%rbp)
	cmpq	$1, -1080(%rbp)
	jle	.L13
	movq	-1080(%rbp), %rax
	subq	$1, %rax
	imulq	-1080(%rbp), %rax
	movq	%rax, %rdx
	shrq	$63, %rdx
	addq	%rdx, %rax
	sarq	%rax
	movq	%rax, %rcx
	movq	-1080(%rbp), %rax
	leaq	-1(%rax), %rdx
	movq	-1080(%rbp), %rax
	subq	$2, %rax
	imulq	%rdx, %rax
	movq	%rax, %rdx
	shrq	$63, %rdx
	addq	%rdx, %rax
	sarq	%rax
	negq	%rax
	addq	%rcx, %rax
	movq	%rax, -1120(%rbp)
.L13:
	movq	-1128(%rbp), %rax
	subq	-1120(%rbp), %rax
	movq	%rax, -1072(%rbp)
	movq	-1072(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	addl	$1, -1136(%rbp)
.L12:
	movl	-1136(%rbp), %eax
	cmpl	-1132(%rbp), %eax
	jl	.L14
	movl	$0, %eax
.L15:
	movq	-24(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L16
	call	__stack_chk_fail@PLT
.L16:
	movq	-8(%rbp), %rbx
	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	" "
.LC1:
	.string	"%lld\n"
	.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
	pushq	%rbx
	subq	$1160, %rsp
	.cfi_offset 3, -24
	movl	%edi, -1156(%rbp)
	movq	%rsi, -1168(%rbp)
	movq	%fs:40, %rax
	movq	%rax, -24(%rbp)
	xorl	%eax, %eax
	movq	$0, -1056(%rbp)
	movq	$0, -1048(%rbp)
	leaq	-1040(%rbp), %rdx
	movl	$0, %eax
	movl	$126, %ecx
	movq	%rdx, %rdi
	rep stosq
	movq	%rdi, %rdx
	movb	%al, (%rdx)
	addq	$1, %rdx
	movq	$0, -1112(%rbp)
	movq	$0, -1104(%rbp)
	movl	$0, -1132(%rbp)
	movq	$0, -1096(%rbp)
	movq	$0, -1088(%rbp)
	movl	$7, %esi
	movl	$200001, %edi
	call	calloc@PLT
	movq	%rax, -1112(%rbp)
	movq	stdin(%rip), %rdx
	movq	-1112(%rbp), %rax
	movl	$7, %esi
	movq	%rax, %rdi
	call	fgets@PLT
	testq	%rax, %rax
	jne	.L2
	movl	$1, %eax
	jmp	.L15
.L2:
	movq	-1112(%rbp), %rax
	movq	%rax, %rdi
	call	atoi@PLT
	movl	%eax, -1132(%rbp)
	movl	-1132(%rbp), %eax
	addl	$1, %eax
	cltq
	movl	$4, %esi
	movq	%rax, %rdi
	call	calloc@PLT
	movq	%rax, -1096(%rbp)
	movl	-1132(%rbp), %eax
	addl	$2, %eax
	cltq
	movl	$4, %esi
	movq	%rax, %rdi
	call	calloc@PLT
	movq	%rax, -1088(%rbp)
	movl	$0, -1148(%rbp)
	jmp	.L4
.L5:
	movl	-1148(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-1088(%rbp), %rax
	addq	%rdx, %rax
	movl	$0, (%rax)
	addl	$1, -1148(%rbp)
.L4:
	movl	-1132(%rbp), %eax
	cmpl	-1148(%rbp), %eax
	jge	.L5
	movl	-1132(%rbp), %edx
	movl	%edx, %eax
	sall	$3, %eax
	subl	%edx, %eax
	addl	$1, %eax
	movslq	%eax, %rdx
	movq	-1112(%rbp), %rax
	movl	$0, %esi
	movq	%rax, %rdi
	call	memset@PLT
	jmp	.L6
.L7:
	leaq	-1056(%rbp), %rdx
	movq	-1112(%rbp), %rax
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	strcat@PLT
	leaq	-1056(%rbp), %rax
	movl	$1025, %edx
	movl	$0, %esi
	movq	%rax, %rdi
	call	memset@PLT
.L6:
	movq	stdin(%rip), %rdx
	leaq	-1056(%rbp), %rax
	movl	$1024, %esi
	movq	%rax, %rdi
	call	fgets@PLT
	testq	%rax, %rax
	jne	.L7
	movq	-1112(%rbp), %rax
	leaq	.LC0(%rip), %rdx
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	strtok@PLT
	movq	%rax, -1104(%rbp)
	movq	-1104(%rbp), %rax
	movq	%rax, %rdi
	call	atoi@PLT
	movq	-1096(%rbp), %rdx
	movl	%eax, (%rdx)
	movq	-1096(%rbp), %rax
	movl	(%rax), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-1088(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %edx
	addl	$1, %edx
	movl	%edx, (%rax)
	movl	$1, -1144(%rbp)
	jmp	.L8
.L9:
	leaq	.LC0(%rip), %rax
	movq	%rax, %rsi
	movl	$0, %edi
	call	strtok@PLT
	movq	%rax, -1104(%rbp)
	movl	-1144(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-1096(%rbp), %rax
	leaq	(%rdx,%rax), %rbx
	movq	-1104(%rbp), %rax
	movq	%rax, %rdi
	call	atoi@PLT
	movl	%eax, (%rbx)
	movl	-1144(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-1096(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-1088(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %edx
	addl	$1, %edx
	movl	%edx, (%rax)
	addl	$1, -1144(%rbp)
.L8:
	movl	-1144(%rbp), %eax
	cmpl	-1132(%rbp), %eax
	jl	.L9
	movq	$0, -1128(%rbp)
	movl	$1, -1140(%rbp)
	jmp	.L10
.L11:
	movl	-1140(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-1088(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	cltq
	movq	%rax, -1064(%rbp)
	movq	-1064(%rbp), %rax
	subq	$1, %rax
	imulq	-1064(%rbp), %rax
	movq	%rax, %rdx
	shrq	$63, %rdx
	addq	%rdx, %rax
	sarq	%rax
	addq	%rax, -1128(%rbp)
	addl	$1, -1140(%rbp)
.L10:
	movl	-1132(%rbp), %eax
	cmpl	-1140(%rbp), %eax
	jge	.L11
	movl	$0, -1136(%rbp)
	jmp	.L12
.L14:
	movl	-1136(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-1096(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-1088(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	cltq
	movq	%rax, -1080(%rbp)
	movq	$0, -1120(%rbp)
	cmpq	$1, -1080(%rbp)
	jle	.L13
	movq	-1080(%rbp), %rax
	subq	$1, %rax
	imulq	-1080(%rbp), %rax
	movq	%rax, %rdx
	shrq	$63, %rdx
	addq	%rdx, %rax
	sarq	%rax
	movq	%rax, %rcx
	movq	-1080(%rbp), %rax
	leaq	-1(%rax), %rdx
	movq	-1080(%rbp), %rax
	subq	$2, %rax
	imulq	%rdx, %rax
	movq	%rax, %rdx
	shrq	$63, %rdx
	addq	%rdx, %rax
	sarq	%rax
	negq	%rax
	addq	%rcx, %rax
	movq	%rax, -1120(%rbp)
.L13:
	movq	-1128(%rbp), %rax
	subq	-1120(%rbp), %rax
	movq	%rax, -1072(%rbp)
	movq	-1072(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	addl	$1, -1136(%rbp)
.L12:
	movl	-1136(%rbp), %eax
	cmpl	-1132(%rbp), %eax
	jl	.L14
	movl	$0, %eax
.L15:
	movq	-24(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L16
	call	__stack_chk_fail@PLT
.L16:
	movq	-8(%rbp), %rbx
	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:
