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

typedef long long ll;

int asc(const void *arg1,const void *arg2) {return *((int *)arg2)-*((int *)arg1);}

bool used[100000],flag;
ll n,a[100000],count=0;

void dfs(int x){
  	count++;
    if(used[x-1]){ flag=false; return;}
    if(a[x-1]==2){ flag=true; return;} 
  	used[x-1]=true;
  	dfs(a[x-1]);
}

int main(){
    scanf("%lld",&n);
    for(int i=0;i<n;i++) scanf("%lld",&a[i]);
    dfs(1);
    if(flag)printf("%lld",count);
    else printf("-1");
    
    return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	asc
	.type	asc, @function
asc:
.LFB6:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movq	%rdi, -8(%rbp)
	movq	%rsi, -16(%rbp)
	movq	-16(%rbp), %rax
	movl	(%rax), %edx
	movq	-8(%rbp), %rax
	movl	(%rax), %ecx
	movl	%edx, %eax
	subl	%ecx, %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	asc, .-asc
	.globl	used
	.bss
	.align 32
	.type	used, @object
	.size	used, 100000
used:
	.zero	100000
	.globl	flag
	.type	flag, @object
	.size	flag, 1
flag:
	.zero	1
	.globl	n
	.align 8
	.type	n, @object
	.size	n, 8
n:
	.zero	8
	.globl	a
	.align 32
	.type	a, @object
	.size	a, 800000
a:
	.zero	800000
	.globl	count
	.align 8
	.type	count, @object
	.size	count, 8
count:
	.zero	8
	.text
	.globl	dfs
	.type	dfs, @function
dfs:
.LFB7:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$16, %rsp
	movl	%edi, -4(%rbp)
	movq	count(%rip), %rax
	addq	$1, %rax
	movq	%rax, count(%rip)
	movl	-4(%rbp), %eax
	subl	$1, %eax
	cltq
	leaq	used(%rip), %rdx
	movzbl	(%rax,%rdx), %eax
	testb	%al, %al
	je	.L4
	movb	$0, flag(%rip)
	jmp	.L3
.L4:
	movl	-4(%rbp), %eax
	subl	$1, %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	a(%rip), %rax
	movq	(%rdx,%rax), %rax
	cmpq	$2, %rax
	jne	.L6
	movb	$1, flag(%rip)
	jmp	.L3
.L6:
	movl	-4(%rbp), %eax
	subl	$1, %eax
	cltq
	leaq	used(%rip), %rdx
	movb	$1, (%rax,%rdx)
	movl	-4(%rbp), %eax
	subl	$1, %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	a(%rip), %rax
	movq	(%rdx,%rax), %rax
	movl	%eax, %edi
	call	dfs
.L3:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.size	dfs, .-dfs
	.section	.rodata
.LC0:
	.string	"%lld"
.LC1:
	.string	"-1"
	.text
	.globl	main
	.type	main, @function
main:
.LFB8:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$16, %rsp
	leaq	n(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -4(%rbp)
	jmp	.L8
.L9:
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	a(%rip), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -4(%rbp)
.L8:
	movl	-4(%rbp), %eax
	movslq	%eax, %rdx
	movq	n(%rip), %rax
	cmpq	%rax, %rdx
	jl	.L9
	movl	$1, %edi
	call	dfs
	movzbl	flag(%rip), %eax
	testb	%al, %al
	je	.L10
	movq	count(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L11
.L10:
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L11:
	movl	$0, %eax
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE8:
	.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	asc
	.type	asc, @function
asc:
.LFB51:
	.cfi_startproc
	endbr64
	movl	(%rsi), %eax
	subl	(%rdi), %eax
	ret
	.cfi_endproc
.LFE51:
	.size	asc, .-asc
	.p2align 4
	.globl	dfs
	.type	dfs, @function
dfs:
.LFB52:
	.cfi_startproc
	endbr64
	subl	$1, %edi
	movq	count(%rip), %rax
	leaq	used(%rip), %rcx
	leaq	a(%rip), %r8
	movslq	%edi, %rdi
	movzbl	(%rcx,%rdi), %esi
	leaq	1(%rax), %rdx
	movq	%rdx, count(%rip)
	testb	%sil, %sil
	je	.L4
	jmp	.L8
	.p2align 4,,10
	.p2align 3
.L6:
	movb	$1, (%rcx,%rdi)
	leal	-1(%rax), %edi
	addq	$1, %rdx
	movl	$1, %esi
	movslq	%edi, %rdi
	cmpb	$0, (%rcx,%rdi)
	jne	.L15
.L4:
	movq	(%r8,%rdi,8), %rax
	cmpq	$2, %rax
	jne	.L6
	testb	%sil, %sil
	je	.L7
	movq	%rdx, count(%rip)
.L7:
	movl	$1, %eax
	movb	%al, flag(%rip)
	ret
	.p2align 4,,10
	.p2align 3
.L15:
	movq	%rdx, count(%rip)
.L8:
	xorl	%eax, %eax
	movb	%al, flag(%rip)
	ret
	.cfi_endproc
.LFE52:
	.size	dfs, .-dfs
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%lld"
.LC1:
	.string	"-1"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB53:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	leaq	.LC0(%rip), %r12
	xorl	%eax, %eax
	leaq	n(%rip), %rsi
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	movq	%r12, %rdi
	leaq	a(%rip), %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	xorl	%ebx, %ebx
	call	__isoc99_scanf@PLT
	cmpq	$0, n(%rip)
	jle	.L21
	.p2align 4,,10
	.p2align 3
.L20:
	movq	%rbp, %rsi
	xorl	%eax, %eax
	movq	%r12, %rdi
	addq	$1, %rbx
	call	__isoc99_scanf@PLT
	addq	$8, %rbp
	cmpq	%rbx, n(%rip)
	jg	.L20
.L21:
	movq	count(%rip), %rax
	movzbl	used(%rip), %esi
	leaq	1(%rax), %r8
	movq	%r8, count(%rip)
	testb	%sil, %sil
	jne	.L18
	leaq	a(%rip), %rdi
	xorl	%edx, %edx
	leaq	used(%rip), %rcx
	jmp	.L19
	.p2align 4,,10
	.p2align 3
.L23:
	subl	$1, %eax
	movb	$1, (%rcx,%rdx)
	addq	$1, %r8
	movl	$1, %esi
	movslq	%eax, %rdx
	cmpb	$0, (%rcx,%rdx)
	jne	.L33
.L19:
	movq	(%rdi,%rdx,8), %rax
	cmpq	$2, %rax
	jne	.L23
	testb	%sil, %sil
	je	.L24
	movq	%r8, count(%rip)
.L24:
	movq	%r8, %rdx
	movq	%r12, %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	movb	$1, flag(%rip)
	call	__printf_chk@PLT
.L22:
	popq	%rbx
	.cfi_remember_state
	.cfi_def_cfa_offset 24
	xorl	%eax, %eax
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
.L33:
	.cfi_restore_state
	movq	%r8, count(%rip)
.L18:
	leaq	.LC1(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	movb	$0, flag(%rip)
	call	__printf_chk@PLT
	jmp	.L22
	.cfi_endproc
.LFE53:
	.size	main, .-main
	.globl	count
	.bss
	.align 8
	.type	count, @object
	.size	count, 8
count:
	.zero	8
	.globl	a
	.align 32
	.type	a, @object
	.size	a, 800000
a:
	.zero	800000
	.globl	n
	.align 8
	.type	n, @object
	.size	n, 8
n:
	.zero	8
	.globl	flag
	.type	flag, @object
	.size	flag, 1
flag:
	.zero	1
	.globl	used
	.align 32
	.type	used, @object
	.size	used, 100000
used:
	.zero	100000
	.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	asc
	.type	asc, @function
asc:
.LFB51:
	.cfi_startproc
	endbr64
	movl	(%rsi), %eax
	subl	(%rdi), %eax
	ret
	.cfi_endproc
.LFE51:
	.size	asc, .-asc
	.p2align 4
	.globl	dfs
	.type	dfs, @function
dfs:
.LFB52:
	.cfi_startproc
	endbr64
	subl	$1, %edi
	movq	count(%rip), %rax
	leaq	used(%rip), %rcx
	leaq	a(%rip), %r8
	movslq	%edi, %rdi
	movzbl	(%rcx,%rdi), %esi
	leaq	1(%rax), %rdx
	movq	%rdx, count(%rip)
	testb	%sil, %sil
	je	.L4
	jmp	.L8
	.p2align 4,,10
	.p2align 3
.L6:
	movb	$1, (%rcx,%rdi)
	leal	-1(%rax), %edi
	addq	$1, %rdx
	movl	$1, %esi
	movslq	%edi, %rdi
	cmpb	$0, (%rcx,%rdi)
	jne	.L15
.L4:
	movq	(%r8,%rdi,8), %rax
	cmpq	$2, %rax
	jne	.L6
	testb	%sil, %sil
	je	.L7
	movq	%rdx, count(%rip)
.L7:
	movl	$1, %eax
	movb	%al, flag(%rip)
	ret
	.p2align 4,,10
	.p2align 3
.L15:
	movq	%rdx, count(%rip)
.L8:
	xorl	%eax, %eax
	movb	%al, flag(%rip)
	ret
	.cfi_endproc
.LFE52:
	.size	dfs, .-dfs
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%lld"
.LC1:
	.string	"-1"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB53:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	leaq	.LC0(%rip), %r12
	xorl	%eax, %eax
	leaq	n(%rip), %rsi
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	movq	%r12, %rdi
	leaq	a(%rip), %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	xorl	%ebx, %ebx
	call	__isoc99_scanf@PLT
	cmpq	$0, n(%rip)
	jle	.L21
	.p2align 4,,10
	.p2align 3
.L20:
	movq	%rbp, %rsi
	xorl	%eax, %eax
	movq	%r12, %rdi
	addq	$1, %rbx
	call	__isoc99_scanf@PLT
	addq	$8, %rbp
	cmpq	%rbx, n(%rip)
	jg	.L20
.L21:
	movq	count(%rip), %rax
	movzbl	used(%rip), %esi
	leaq	1(%rax), %r8
	movq	%r8, count(%rip)
	testb	%sil, %sil
	jne	.L18
	leaq	a(%rip), %rdi
	xorl	%edx, %edx
	leaq	used(%rip), %rcx
	jmp	.L19
	.p2align 4,,10
	.p2align 3
.L23:
	subl	$1, %eax
	movb	$1, (%rcx,%rdx)
	addq	$1, %r8
	movl	$1, %esi
	movslq	%eax, %rdx
	cmpb	$0, (%rcx,%rdx)
	jne	.L33
.L19:
	movq	(%rdi,%rdx,8), %rax
	cmpq	$2, %rax
	jne	.L23
	testb	%sil, %sil
	je	.L24
	movq	%r8, count(%rip)
.L24:
	movq	%r8, %rdx
	movq	%r12, %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	movb	$1, flag(%rip)
	call	__printf_chk@PLT
.L22:
	popq	%rbx
	.cfi_remember_state
	.cfi_def_cfa_offset 24
	xorl	%eax, %eax
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
.L33:
	.cfi_restore_state
	movq	%r8, count(%rip)
.L18:
	leaq	.LC1(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	movb	$0, flag(%rip)
	call	__printf_chk@PLT
	jmp	.L22
	.cfi_endproc
.LFE53:
	.size	main, .-main
	.globl	count
	.bss
	.align 8
	.type	count, @object
	.size	count, 8
count:
	.zero	8
	.globl	a
	.align 32
	.type	a, @object
	.size	a, 800000
a:
	.zero	800000
	.globl	n
	.align 8
	.type	n, @object
	.size	n, 8
n:
	.zero	8
	.globl	flag
	.type	flag, @object
	.size	flag, 1
flag:
	.zero	1
	.globl	used
	.align 32
	.type	used, @object
	.size	used, 100000
used:
	.zero	100000
	.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<string.h>
#include<stdlib.h>
#include<math.h>
#include<stdbool.h>

typedef long long ll;

int asc(const void *arg1,const void *arg2) {return *((int *)arg2)-*((int *)arg1);}

bool used[100000],flag;
ll n,a[100000],count=0;

void dfs(int x){
  	count++;
    if(used[x-1]){ flag=false; return;}
    if(a[x-1]==2){ flag=true; return;} 
  	used[x-1]=true;
  	dfs(a[x-1]);
}

int main(){
    scanf("%lld",&n);
    for(int i=0;i<n;i++) scanf("%lld",&a[i]);
    dfs(1);
    if(flag)printf("%lld",count);
    else printf("-1");
    
    return 0;
}
3
3
1
3
 5
3
3
5
2
4
 4
4
3
1
2
 3
2
2
1
 5
3
0
4
2
4
 4
3
3
1
2
 3
3
2
3
 4
4
3
0
2
 4
4
4
0
2
 4
4
7
0
2

-1 4 2 1 3 -1 -1 2 2 2
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<string.h>
#include<stdlib.h>
#include<math.h>
#include<stdbool.h>

typedef long long ll;

int asc(const void *arg1,const void *arg2) {return *((int *)arg2)-*((int *)arg1);}

bool used[100000],flag;
ll n,a[100000],count=0;

void dfs(int x){
  	count++;
    if(used[x-1]){ flag=false; return;}
    if(a[x-1]==2){ flag=true; return;} 
  	used[x-1]=true;
  	dfs(a[x-1]);
}

int main(){
    scanf("%lld",&n);
    for(int i=0;i<n;i++) scanf("%lld",&a[i]);
    dfs(1);
    if(flag)printf("%lld",count);
    else printf("-1");
    
    return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	asc
	.type	asc, @function
asc:
.LFB6:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movq	%rdi, -8(%rbp)
	movq	%rsi, -16(%rbp)
	movq	-16(%rbp), %rax
	movl	(%rax), %edx
	movq	-8(%rbp), %rax
	movl	(%rax), %ecx
	movl	%edx, %eax
	subl	%ecx, %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	asc, .-asc
	.globl	used
	.bss
	.align 32
	.type	used, @object
	.size	used, 100000
used:
	.zero	100000
	.globl	flag
	.type	flag, @object
	.size	flag, 1
flag:
	.zero	1
	.globl	n
	.align 8
	.type	n, @object
	.size	n, 8
n:
	.zero	8
	.globl	a
	.align 32
	.type	a, @object
	.size	a, 800000
a:
	.zero	800000
	.globl	count
	.align 8
	.type	count, @object
	.size	count, 8
count:
	.zero	8
	.text
	.globl	dfs
	.type	dfs, @function
dfs:
.LFB7:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$16, %rsp
	movl	%edi, -4(%rbp)
	movq	count(%rip), %rax
	addq	$1, %rax
	movq	%rax, count(%rip)
	movl	-4(%rbp), %eax
	subl	$1, %eax
	cltq
	leaq	used(%rip), %rdx
	movzbl	(%rax,%rdx), %eax
	testb	%al, %al
	je	.L4
	movb	$0, flag(%rip)
	jmp	.L3
.L4:
	movl	-4(%rbp), %eax
	subl	$1, %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	a(%rip), %rax
	movq	(%rdx,%rax), %rax
	cmpq	$2, %rax
	jne	.L6
	movb	$1, flag(%rip)
	jmp	.L3
.L6:
	movl	-4(%rbp), %eax
	subl	$1, %eax
	cltq
	leaq	used(%rip), %rdx
	movb	$1, (%rax,%rdx)
	movl	-4(%rbp), %eax
	subl	$1, %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	a(%rip), %rax
	movq	(%rdx,%rax), %rax
	movl	%eax, %edi
	call	dfs
.L3:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.size	dfs, .-dfs
	.section	.rodata
.LC0:
	.string	"%lld"
.LC1:
	.string	"-1"
	.text
	.globl	main
	.type	main, @function
main:
.LFB8:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$16, %rsp
	leaq	n(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -4(%rbp)
	jmp	.L8
.L9:
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	a(%rip), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -4(%rbp)
.L8:
	movl	-4(%rbp), %eax
	movslq	%eax, %rdx
	movq	n(%rip), %rax
	cmpq	%rax, %rdx
	jl	.L9
	movl	$1, %edi
	call	dfs
	movzbl	flag(%rip), %eax
	testb	%al, %al
	je	.L10
	movq	count(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L11
.L10:
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L11:
	movl	$0, %eax
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE8:
	.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	asc
	.type	asc, @function
asc:
.LFB6:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movq	%rdi, -8(%rbp)
	movq	%rsi, -16(%rbp)
	movq	-16(%rbp), %rax
	movl	(%rax), %edx
	movq	-8(%rbp), %rax
	movl	(%rax), %ecx
	movl	%edx, %eax
	subl	%ecx, %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	asc, .-asc
	.globl	used
	.bss
	.align 32
	.type	used, @object
	.size	used, 100000
used:
	.zero	100000
	.globl	flag
	.type	flag, @object
	.size	flag, 1
flag:
	.zero	1
	.globl	n
	.align 8
	.type	n, @object
	.size	n, 8
n:
	.zero	8
	.globl	a
	.align 32
	.type	a, @object
	.size	a, 800000
a:
	.zero	800000
	.globl	count
	.align 8
	.type	count, @object
	.size	count, 8
count:
	.zero	8
	.text
	.globl	dfs
	.type	dfs, @function
dfs:
.LFB7:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$16, %rsp
	movl	%edi, -4(%rbp)
	movq	count(%rip), %rax
	addq	$1, %rax
	movq	%rax, count(%rip)
	movl	-4(%rbp), %eax
	subl	$1, %eax
	cltq
	leaq	used(%rip), %rdx
	movzbl	(%rax,%rdx), %eax
	testb	%al, %al
	je	.L4
	movb	$0, flag(%rip)
	jmp	.L3
.L4:
	movl	-4(%rbp), %eax
	subl	$1, %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	a(%rip), %rax
	movq	(%rdx,%rax), %rax
	cmpq	$2, %rax
	jne	.L6
	movb	$1, flag(%rip)
	jmp	.L3
.L6:
	movl	-4(%rbp), %eax
	subl	$1, %eax
	cltq
	leaq	used(%rip), %rdx
	movb	$1, (%rax,%rdx)
	movl	-4(%rbp), %eax
	subl	$1, %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	a(%rip), %rax
	movq	(%rdx,%rax), %rax
	movl	%eax, %edi
	call	dfs
.L3:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.size	dfs, .-dfs
	.section	.rodata
.LC0:
	.string	"%lld"
.LC1:
	.string	"-1"
	.text
	.globl	main
	.type	main, @function
main:
.LFB8:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$16, %rsp
	leaq	n(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -4(%rbp)
	jmp	.L8
.L9:
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	a(%rip), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -4(%rbp)
.L8:
	movl	-4(%rbp), %eax
	movslq	%eax, %rdx
	movq	n(%rip), %rax
	cmpq	%rax, %rdx
	jl	.L9
	movl	$1, %edi
	call	dfs
	movzbl	flag(%rip), %eax
	testb	%al, %al
	je	.L10
	movq	count(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L11
.L10:
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L11:
	movl	$0, %eax
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE8:
	.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:
