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<math.h>

int counting(long n){
    long i;
    long count=n;
    double l=sqrt(n);

    for(i=2;i<=l;i++){
        if(!(n%i)){
            while(!(n%i)){
                n/=i;
            }
            count=(count*(i-1))/i;
        }
    }

    if(n!=1)count=(count*(n-1))/n;

    return count;
}

int main(void){
    long n;
    long count;
    
    scanf("%ld", &n);

    count=counting(n);

    printf("%ld\n", count);
}
```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	counting
	.type	counting, @function
counting:
.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	%rdi, -40(%rbp)
	movq	-40(%rbp), %rax
	movq	%rax, -16(%rbp)
	pxor	%xmm2, %xmm2
	cvtsi2sdq	-40(%rbp), %xmm2
	movq	%xmm2, %rax
	movq	%rax, %xmm0
	call	sqrt@PLT
	movq	%xmm0, %rax
	movq	%rax, -8(%rbp)
	movq	$2, -24(%rbp)
	jmp	.L2
.L6:
	movq	-40(%rbp), %rax
	cqto
	idivq	-24(%rbp)
	movq	%rdx, %rax
	testq	%rax, %rax
	jne	.L3
	jmp	.L4
.L5:
	movq	-40(%rbp), %rax
	cqto
	idivq	-24(%rbp)
	movq	%rax, -40(%rbp)
.L4:
	movq	-40(%rbp), %rax
	cqto
	idivq	-24(%rbp)
	movq	%rdx, %rax
	testq	%rax, %rax
	je	.L5
	movq	-24(%rbp), %rax
	subq	$1, %rax
	imulq	-16(%rbp), %rax
	cqto
	idivq	-24(%rbp)
	movq	%rax, -16(%rbp)
.L3:
	addq	$1, -24(%rbp)
.L2:
	pxor	%xmm1, %xmm1
	cvtsi2sdq	-24(%rbp), %xmm1
	movsd	-8(%rbp), %xmm0
	comisd	%xmm1, %xmm0
	jnb	.L6
	cmpq	$1, -40(%rbp)
	je	.L7
	movq	-40(%rbp), %rax
	subq	$1, %rax
	imulq	-16(%rbp), %rax
	cqto
	idivq	-40(%rbp)
	movq	%rax, -16(%rbp)
.L7:
	movq	-16(%rbp), %rax
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	counting, .-counting
	.section	.rodata
.LC0:
	.string	"%ld"
.LC1:
	.string	"%ld\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB1:
	.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
	leaq	-24(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movq	-24(%rbp), %rax
	movq	%rax, %rdi
	call	counting
	cltq
	movq	%rax, -16(%rbp)
	movq	-16(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L11
	call	__stack_chk_fail@PLT
.L11:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.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
	.p2align 4
	.globl	counting
	.type	counting, @function
counting:
.LFB23:
	.cfi_startproc
	endbr64
	pxor	%xmm0, %xmm0
	pxor	%xmm1, %xmm1
	subq	$24, %rsp
	.cfi_def_cfa_offset 32
	cvtsi2sdq	%rdi, %xmm0
	ucomisd	%xmm0, %xmm1
	ja	.L21
	sqrtsd	%xmm0, %xmm0
.L4:
	comisd	.LC1(%rip), %xmm0
	movq	%rdi, %rsi
	movl	$2, %ecx
	jnb	.L9
	jmp	.L5
	.p2align 4,,10
	.p2align 3
.L7:
	addq	$1, %rcx
	pxor	%xmm1, %xmm1
	cvtsi2sdq	%rcx, %xmm1
	comisd	%xmm1, %xmm0
	jb	.L5
.L9:
	movq	%rdi, %rax
	cqto
	idivq	%rcx
	testq	%rdx, %rdx
	jne	.L7
	.p2align 4,,10
	.p2align 3
.L8:
	movq	%rdi, %rax
	cqto
	idivq	%rcx
	cqto
	movq	%rax, %rdi
	idivq	%rcx
	testq	%rdx, %rdx
	je	.L8
	leaq	-1(%rcx), %rax
	pxor	%xmm1, %xmm1
	imulq	%rsi, %rax
	cqto
	idivq	%rcx
	addq	$1, %rcx
	cvtsi2sdq	%rcx, %xmm1
	comisd	%xmm1, %xmm0
	movq	%rax, %rsi
	jnb	.L9
.L5:
	cmpq	$1, %rdi
	je	.L10
	leaq	-1(%rdi), %rax
	imulq	%rsi, %rax
	cqto
	idivq	%rdi
	movq	%rax, %rsi
.L10:
	movl	%esi, %eax
	addq	$24, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 8
	ret
.L21:
	.cfi_restore_state
	movq	%rdi, 8(%rsp)
	call	sqrt@PLT
	movq	8(%rsp), %rdi
	jmp	.L4
	.cfi_endproc
.LFE23:
	.size	counting, .-counting
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC2:
	.string	"%ld"
.LC3:
	.string	"%ld\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB24:
	.cfi_startproc
	endbr64
	subq	$24, %rsp
	.cfi_def_cfa_offset 32
	leaq	.LC2(%rip), %rdi
	movq	%fs:40, %rax
	movq	%rax, 8(%rsp)
	xorl	%eax, %eax
	movq	%rsp, %rsi
	call	__isoc99_scanf@PLT
	movq	(%rsp), %rdi
	call	counting
	leaq	.LC3(%rip), %rsi
	movl	$1, %edi
	movslq	%eax, %rdx
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	8(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L27
	xorl	%eax, %eax
	addq	$24, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 8
	ret
.L27:
	.cfi_restore_state
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE24:
	.size	main, .-main
	.section	.rodata.cst8,"aM",@progbits,8
	.align 8
.LC1:
	.long	0
	.long	1073741824
	.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
	.p2align 4
	.globl	counting
	.type	counting, @function
counting:
.LFB23:
	.cfi_startproc
	endbr64
	pxor	%xmm0, %xmm0
	pxor	%xmm1, %xmm1
	subq	$24, %rsp
	.cfi_def_cfa_offset 32
	cvtsi2sdq	%rdi, %xmm0
	ucomisd	%xmm0, %xmm1
	ja	.L21
	sqrtsd	%xmm0, %xmm0
.L4:
	comisd	.LC1(%rip), %xmm0
	movq	%rdi, %rsi
	movl	$2, %ecx
	jnb	.L9
	jmp	.L5
	.p2align 4,,10
	.p2align 3
.L7:
	addq	$1, %rcx
	pxor	%xmm1, %xmm1
	cvtsi2sdq	%rcx, %xmm1
	comisd	%xmm1, %xmm0
	jb	.L5
.L9:
	movq	%rdi, %rax
	cqto
	idivq	%rcx
	testq	%rdx, %rdx
	jne	.L7
	.p2align 4,,10
	.p2align 3
.L8:
	movq	%rdi, %rax
	cqto
	idivq	%rcx
	cqto
	movq	%rax, %rdi
	idivq	%rcx
	testq	%rdx, %rdx
	je	.L8
	leaq	-1(%rcx), %rax
	pxor	%xmm1, %xmm1
	imulq	%rsi, %rax
	cqto
	idivq	%rcx
	addq	$1, %rcx
	cvtsi2sdq	%rcx, %xmm1
	comisd	%xmm1, %xmm0
	movq	%rax, %rsi
	jnb	.L9
.L5:
	cmpq	$1, %rdi
	je	.L10
	leaq	-1(%rdi), %rax
	imulq	%rsi, %rax
	cqto
	idivq	%rdi
	movq	%rax, %rsi
.L10:
	movl	%esi, %eax
	addq	$24, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 8
	ret
.L21:
	.cfi_restore_state
	movq	%rdi, 8(%rsp)
	call	sqrt@PLT
	movq	8(%rsp), %rdi
	jmp	.L4
	.cfi_endproc
.LFE23:
	.size	counting, .-counting
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC2:
	.string	"%ld"
.LC3:
	.string	"%ld\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB24:
	.cfi_startproc
	endbr64
	subq	$24, %rsp
	.cfi_def_cfa_offset 32
	leaq	.LC2(%rip), %rdi
	movq	%fs:40, %rax
	movq	%rax, 8(%rsp)
	xorl	%eax, %eax
	movq	%rsp, %rsi
	call	__isoc99_scanf@PLT
	movq	(%rsp), %rdi
	call	counting
	leaq	.LC3(%rip), %rsi
	movl	$1, %edi
	movslq	%eax, %rdx
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	8(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L27
	xorl	%eax, %eax
	addq	$24, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 8
	ret
.L27:
	.cfi_restore_state
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE24:
	.size	main, .-main
	.section	.rodata.cst8,"aM",@progbits,8
	.align 8
.LC1:
	.long	0
	.long	1073741824
	.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<math.h>

int counting(long n){
    long i;
    long count=n;
    double l=sqrt(n);

    for(i=2;i<=l;i++){
        if(!(n%i)){
            while(!(n%i)){
                n/=i;
            }
            count=(count*(i-1))/i;
        }
    }

    if(n!=1)count=(count*(n-1))/n;

    return count;
}

int main(void){
    long n;
    long count;
    
    scanf("%ld", &n);

    count=counting(n);

    printf("%ld\n", count);
}

1000100
 5
 1000101
 1000001
 1000011
 16
 1010011
 31
 61
 59

391680
 4
 666732
 990000
 666672
 8
 976500
 30
 60
 58

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<math.h>

int counting(long n){
    long i;
    long count=n;
    double l=sqrt(n);

    for(i=2;i<=l;i++){
        if(!(n%i)){
            while(!(n%i)){
                n/=i;
            }
            count=(count*(i-1))/i;
        }
    }

    if(n!=1)count=(count*(n-1))/n;

    return count;
}

int main(void){
    long n;
    long count;
    
    scanf("%ld", &n);

    count=counting(n);

    printf("%ld\n", count);
}
```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	counting
	.type	counting, @function
counting:
.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	%rdi, -40(%rbp)
	movq	-40(%rbp), %rax
	movq	%rax, -16(%rbp)
	pxor	%xmm2, %xmm2
	cvtsi2sdq	-40(%rbp), %xmm2
	movq	%xmm2, %rax
	movq	%rax, %xmm0
	call	sqrt@PLT
	movq	%xmm0, %rax
	movq	%rax, -8(%rbp)
	movq	$2, -24(%rbp)
	jmp	.L2
.L6:
	movq	-40(%rbp), %rax
	cqto
	idivq	-24(%rbp)
	movq	%rdx, %rax
	testq	%rax, %rax
	jne	.L3
	jmp	.L4
.L5:
	movq	-40(%rbp), %rax
	cqto
	idivq	-24(%rbp)
	movq	%rax, -40(%rbp)
.L4:
	movq	-40(%rbp), %rax
	cqto
	idivq	-24(%rbp)
	movq	%rdx, %rax
	testq	%rax, %rax
	je	.L5
	movq	-24(%rbp), %rax
	subq	$1, %rax
	imulq	-16(%rbp), %rax
	cqto
	idivq	-24(%rbp)
	movq	%rax, -16(%rbp)
.L3:
	addq	$1, -24(%rbp)
.L2:
	pxor	%xmm1, %xmm1
	cvtsi2sdq	-24(%rbp), %xmm1
	movsd	-8(%rbp), %xmm0
	comisd	%xmm1, %xmm0
	jnb	.L6
	cmpq	$1, -40(%rbp)
	je	.L7
	movq	-40(%rbp), %rax
	subq	$1, %rax
	imulq	-16(%rbp), %rax
	cqto
	idivq	-40(%rbp)
	movq	%rax, -16(%rbp)
.L7:
	movq	-16(%rbp), %rax
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	counting, .-counting
	.section	.rodata
.LC0:
	.string	"%ld"
.LC1:
	.string	"%ld\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB1:
	.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
	leaq	-24(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movq	-24(%rbp), %rax
	movq	%rax, %rdi
	call	counting
	cltq
	movq	%rax, -16(%rbp)
	movq	-16(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L11
	call	__stack_chk_fail@PLT
.L11:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.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
	.globl	counting
	.type	counting, @function
counting:
.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	%rdi, -40(%rbp)
	movq	-40(%rbp), %rax
	movq	%rax, -16(%rbp)
	pxor	%xmm2, %xmm2
	cvtsi2sdq	-40(%rbp), %xmm2
	movq	%xmm2, %rax
	movq	%rax, %xmm0
	call	sqrt@PLT
	movq	%xmm0, %rax
	movq	%rax, -8(%rbp)
	movq	$2, -24(%rbp)
	jmp	.L2
.L6:
	movq	-40(%rbp), %rax
	cqto
	idivq	-24(%rbp)
	movq	%rdx, %rax
	testq	%rax, %rax
	jne	.L3
	jmp	.L4
.L5:
	movq	-40(%rbp), %rax
	cqto
	idivq	-24(%rbp)
	movq	%rax, -40(%rbp)
.L4:
	movq	-40(%rbp), %rax
	cqto
	idivq	-24(%rbp)
	movq	%rdx, %rax
	testq	%rax, %rax
	je	.L5
	movq	-24(%rbp), %rax
	subq	$1, %rax
	imulq	-16(%rbp), %rax
	cqto
	idivq	-24(%rbp)
	movq	%rax, -16(%rbp)
.L3:
	addq	$1, -24(%rbp)
.L2:
	pxor	%xmm1, %xmm1
	cvtsi2sdq	-24(%rbp), %xmm1
	movsd	-8(%rbp), %xmm0
	comisd	%xmm1, %xmm0
	jnb	.L6
	cmpq	$1, -40(%rbp)
	je	.L7
	movq	-40(%rbp), %rax
	subq	$1, %rax
	imulq	-16(%rbp), %rax
	cqto
	idivq	-40(%rbp)
	movq	%rax, -16(%rbp)
.L7:
	movq	-16(%rbp), %rax
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	counting, .-counting
	.section	.rodata
.LC0:
	.string	"%ld"
.LC1:
	.string	"%ld\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB1:
	.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
	leaq	-24(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movq	-24(%rbp), %rax
	movq	%rax, %rdi
	call	counting
	cltq
	movq	%rax, -16(%rbp)
	movq	-16(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L11
	call	__stack_chk_fail@PLT
.L11:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.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:
