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

```c
#include <float.h>
#include <inttypes.h>
#include <limits.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <math.h>
#ifdef __cplusplus
#include <bits/stdc++.h>
#endif

uint32_t nextpint(void){ char c=getchar_unlocked(); while(c<'0'||'9'<c) c=getchar_unlocked(); uint32_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar_unlocked(); } return x; }
uint64_t nextplong(void){ char c=getchar_unlocked(); while(c<'0'||'9'<c) c=getchar_unlocked(); uint64_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar_unlocked(); } return x; }

uint32_t a[200001];
uint32_t s[200001];
int main(void){
	uint32_t n=nextpint();
	uint64_t k=nextplong();
	for(uint32_t i=1; i<=n; i++){
		a[i]=nextpint();
	}
	uint32_t now=1;
	for(; k>0; k--){
		now = a[now];
		if(s[now]==0){
			s[now]=k;
		}else{
			uint32_t m=s[now]-k;
			k=(k-1)%m;
			break;
		}
	}
	for(; k>0; k--){
		now = a[now];
	}
	printf("%"PRIu32"\n", now);
}
```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	nextpint
	.type	nextpint, @function
nextpint:
.LFB6:
	.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
	call	getchar_unlocked@PLT
	movb	%al, -5(%rbp)
	jmp	.L2
.L3:
	call	getchar_unlocked@PLT
	movb	%al, -5(%rbp)
.L2:
	cmpb	$47, -5(%rbp)
	jle	.L3
	cmpb	$57, -5(%rbp)
	jg	.L3
	movl	$0, -4(%rbp)
	jmp	.L4
.L6:
	movl	-4(%rbp), %edx
	movl	%edx, %eax
	sall	$2, %eax
	addl	%edx, %eax
	addl	%eax, %eax
	movl	%eax, %edx
	movsbl	-5(%rbp), %eax
	addl	%edx, %eax
	subl	$48, %eax
	movl	%eax, -4(%rbp)
	call	getchar_unlocked@PLT
	movb	%al, -5(%rbp)
.L4:
	cmpb	$47, -5(%rbp)
	jle	.L5
	cmpb	$57, -5(%rbp)
	jle	.L6
.L5:
	movl	-4(%rbp), %eax
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	nextpint, .-nextpint
	.globl	nextplong
	.type	nextplong, @function
nextplong:
.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
	call	getchar_unlocked@PLT
	movb	%al, -9(%rbp)
	jmp	.L9
.L10:
	call	getchar_unlocked@PLT
	movb	%al, -9(%rbp)
.L9:
	cmpb	$47, -9(%rbp)
	jle	.L10
	cmpb	$57, -9(%rbp)
	jg	.L10
	movq	$0, -8(%rbp)
	jmp	.L11
.L13:
	movq	-8(%rbp), %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rax, %rax
	movq	%rax, %rdx
	movsbq	-9(%rbp), %rax
	addq	%rdx, %rax
	subq	$48, %rax
	movq	%rax, -8(%rbp)
	call	getchar_unlocked@PLT
	movb	%al, -9(%rbp)
.L11:
	cmpb	$47, -9(%rbp)
	jle	.L12
	cmpb	$57, -9(%rbp)
	jle	.L13
.L12:
	movq	-8(%rbp), %rax
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.size	nextplong, .-nextplong
	.globl	a
	.bss
	.align 32
	.type	a, @object
	.size	a, 800004
a:
	.zero	800004
	.globl	s
	.align 32
	.type	s, @object
	.size	s, 800004
s:
	.zero	800004
	.section	.rodata
.LC0:
	.string	"%u\n"
	.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	$32, %rsp
	call	nextpint
	movl	%eax, -16(%rbp)
	call	nextplong
	movq	%rax, -8(%rbp)
	movl	$1, -24(%rbp)
	jmp	.L16
.L17:
	call	nextpint
	movl	-24(%rbp), %edx
	leaq	0(,%rdx,4), %rcx
	leaq	a(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	addl	$1, -24(%rbp)
.L16:
	movl	-24(%rbp), %eax
	cmpl	-16(%rbp), %eax
	jbe	.L17
	movl	$1, -20(%rbp)
	jmp	.L18
.L22:
	movl	-20(%rbp), %eax
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -20(%rbp)
	movl	-20(%rbp), %eax
	leaq	0(,%rax,4), %rdx
	leaq	s(%rip), %rax
	movl	(%rdx,%rax), %eax
	testl	%eax, %eax
	jne	.L19
	movq	-8(%rbp), %rax
	movl	%eax, %ecx
	movl	-20(%rbp), %eax
	leaq	0(,%rax,4), %rdx
	leaq	s(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	jmp	.L26
.L19:
	movl	-20(%rbp), %eax
	leaq	0(,%rax,4), %rdx
	leaq	s(%rip), %rax
	movl	(%rdx,%rax), %eax
	movq	-8(%rbp), %rdx
	subl	%edx, %eax
	movl	%eax, -12(%rbp)
	movq	-8(%rbp), %rax
	subq	$1, %rax
	movl	-12(%rbp), %ecx
	movl	$0, %edx
	divq	%rcx
	movq	%rdx, -8(%rbp)
	jmp	.L21
.L26:
	subq	$1, -8(%rbp)
.L18:
	cmpq	$0, -8(%rbp)
	jne	.L22
.L21:
	jmp	.L23
.L24:
	movl	-20(%rbp), %eax
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -20(%rbp)
	subq	$1, -8(%rbp)
.L23:
	cmpq	$0, -8(%rbp)
	jne	.L24
	movl	-20(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	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	nextpint
	.type	nextpint, @function
nextpint:
.LFB63:
	.cfi_startproc
	endbr64
	movq	stdin(%rip), %rdi
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	movq	8(%rdi), %rax
	movq	16(%rdi), %rsi
	cmpq	%rsi, %rax
	jnb	.L17
	leaq	1(%rax), %rcx
	movq	%rcx, 8(%rdi)
	movzbl	(%rax), %edx
	movl	%edx, %eax
.L3:
	subl	$48, %eax
	cmpb	$9, %al
	ja	.L8
	jmp	.L4
	.p2align 4,,10
	.p2align 3
.L5:
	leaq	1(%rcx), %rax
	movq	%rax, 8(%rdi)
	movzbl	(%rcx), %edx
	movl	%edx, %ecx
	subl	$48, %ecx
	cmpb	$9, %cl
	jbe	.L9
.L6:
	movq	%rax, %rcx
.L8:
	cmpq	%rsi, %rcx
	jb	.L5
	call	__uflow@PLT
	movq	stdin(%rip), %rdi
	movl	%eax, %edx
	leal	-48(%rdx), %ecx
	movq	8(%rdi), %rax
	movq	16(%rdi), %rsi
	cmpb	$9, %cl
	ja	.L6
	.p2align 4,,10
	.p2align 3
.L9:
	xorl	%r12d, %r12d
	jmp	.L13
	.p2align 4,,10
	.p2align 3
.L10:
	leaq	1(%rax), %rdx
	movq	%rdx, 8(%rdi)
	movzbl	(%rax), %edx
	leal	-48(%rdx), %eax
	cmpb	$9, %al
	ja	.L1
.L11:
	movq	8(%rdi), %rax
	movq	16(%rdi), %rsi
.L13:
	leal	(%r12,%r12,4), %ecx
	movsbl	%dl, %edx
	leal	-48(%rdx,%rcx,2), %r12d
	cmpq	%rsi, %rax
	jb	.L10
	call	__uflow@PLT
	movl	%eax, %edx
	subl	$48, %eax
	cmpb	$9, %al
	ja	.L1
	movq	stdin(%rip), %rdi
	jmp	.L11
	.p2align 4,,10
	.p2align 3
.L1:
	movl	%r12d, %eax
	popq	%r12
	.cfi_remember_state
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L4:
	.cfi_restore_state
	movq	%rcx, %rax
	jmp	.L9
	.p2align 4,,10
	.p2align 3
.L17:
	call	__uflow@PLT
	movq	stdin(%rip), %rdi
	movl	%eax, %edx
	movq	8(%rdi), %rcx
	movq	16(%rdi), %rsi
	jmp	.L3
	.cfi_endproc
.LFE63:
	.size	nextpint, .-nextpint
	.p2align 4
	.globl	nextplong
	.type	nextplong, @function
nextplong:
.LFB64:
	.cfi_startproc
	endbr64
	movq	stdin(%rip), %rdi
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	movq	8(%rdi), %rax
	movq	16(%rdi), %rsi
	cmpq	%rsi, %rax
	jnb	.L33
	leaq	1(%rax), %rcx
	movq	%rcx, 8(%rdi)
	movzbl	(%rax), %edx
	movl	%edx, %eax
.L20:
	subl	$48, %eax
	cmpb	$9, %al
	ja	.L25
	jmp	.L21
	.p2align 4,,10
	.p2align 3
.L22:
	leaq	1(%rcx), %rax
	movq	%rax, 8(%rdi)
	movzbl	(%rcx), %edx
	movl	%edx, %ecx
	subl	$48, %ecx
	cmpb	$9, %cl
	jbe	.L26
.L23:
	movq	%rax, %rcx
.L25:
	cmpq	%rsi, %rcx
	jb	.L22
	call	__uflow@PLT
	movq	stdin(%rip), %rdi
	movl	%eax, %edx
	leal	-48(%rdx), %ecx
	movq	8(%rdi), %rax
	movq	16(%rdi), %rsi
	cmpb	$9, %cl
	ja	.L23
	.p2align 4,,10
	.p2align 3
.L26:
	xorl	%r12d, %r12d
	jmp	.L30
	.p2align 4,,10
	.p2align 3
.L27:
	leaq	1(%rax), %rdx
	movq	%rdx, 8(%rdi)
	movzbl	(%rax), %edx
	leal	-48(%rdx), %eax
	cmpb	$9, %al
	ja	.L18
.L28:
	movq	8(%rdi), %rax
	movq	16(%rdi), %rsi
.L30:
	leaq	(%r12,%r12,4), %rcx
	movsbq	%dl, %rdx
	leaq	-48(%rdx,%rcx,2), %r12
	cmpq	%rsi, %rax
	jb	.L27
	call	__uflow@PLT
	movl	%eax, %edx
	subl	$48, %eax
	cmpb	$9, %al
	ja	.L18
	movq	stdin(%rip), %rdi
	jmp	.L28
	.p2align 4,,10
	.p2align 3
.L18:
	movq	%r12, %rax
	popq	%r12
	.cfi_remember_state
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L21:
	.cfi_restore_state
	movq	%rcx, %rax
	jmp	.L26
	.p2align 4,,10
	.p2align 3
.L33:
	call	__uflow@PLT
	movq	stdin(%rip), %rdi
	movl	%eax, %edx
	movq	8(%rdi), %rcx
	movq	16(%rdi), %rsi
	jmp	.L20
	.cfi_endproc
.LFE64:
	.size	nextplong, .-nextplong
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%u\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB65:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	leaq	a(%rip), %r12
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	movl	$1, %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	subq	$8, %rsp
	.cfi_def_cfa_offset 48
	call	nextpint
	movl	%eax, %r13d
	call	nextplong
	movq	%rax, %rbx
	testl	%r13d, %r13d
	je	.L38
	.p2align 4,,10
	.p2align 3
.L35:
	call	nextpint
	movl	%eax, (%r12,%rbp,4)
	addq	$1, %rbp
	cmpl	%ebp, %r13d
	jnb	.L35
.L38:
	leaq	a(%rip), %r12
	movl	$1, %ecx
	leaq	s(%rip), %rdx
	movl	$1, %r8d
	testq	%rbx, %rbx
	jne	.L36
	jmp	.L37
	.p2align 4,,10
	.p2align 3
.L53:
	movl	%edi, (%rdx,%rcx,4)
	testq	%rbx, %rbx
	je	.L37
.L36:
	movl	(%r12,%rcx,4), %ecx
	movl	%ebx, %edi
	subq	$1, %rbx
	movl	(%rdx,%rcx,4), %eax
	movq	%rcx, %r8
	testl	%eax, %eax
	je	.L53
	movl	%eax, %esi
	xorl	%edx, %edx
	movq	%rbx, %rax
	subl	%edi, %esi
	divq	%rsi
	testq	%rdx, %rdx
	jne	.L40
	jmp	.L37
	.p2align 4,,10
	.p2align 3
.L54:
	movl	%r8d, %ecx
.L40:
	movl	(%r12,%rcx,4), %r8d
	subq	$1, %rdx
	jne	.L54
.L37:
	movl	%r8d, %edx
	leaq	.LC0(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	addq	$8, %rsp
	.cfi_def_cfa_offset 40
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%rbp
	.cfi_def_cfa_offset 24
	popq	%r12
	.cfi_def_cfa_offset 16
	popq	%r13
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE65:
	.size	main, .-main
	.globl	s
	.bss
	.align 32
	.type	s, @object
	.size	s, 800004
s:
	.zero	800004
	.globl	a
	.align 32
	.type	a, @object
	.size	a, 800004
a:
	.zero	800004
	.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	nextpint
	.type	nextpint, @function
nextpint:
.LFB63:
	.cfi_startproc
	endbr64
	movq	stdin(%rip), %rdi
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	movq	8(%rdi), %rax
	movq	16(%rdi), %rsi
	cmpq	%rsi, %rax
	jnb	.L17
	leaq	1(%rax), %rcx
	movq	%rcx, 8(%rdi)
	movzbl	(%rax), %edx
	movl	%edx, %eax
.L3:
	subl	$48, %eax
	cmpb	$9, %al
	ja	.L8
	jmp	.L4
	.p2align 4,,10
	.p2align 3
.L5:
	leaq	1(%rcx), %rax
	movq	%rax, 8(%rdi)
	movzbl	(%rcx), %edx
	movl	%edx, %ecx
	subl	$48, %ecx
	cmpb	$9, %cl
	jbe	.L9
.L6:
	movq	%rax, %rcx
.L8:
	cmpq	%rsi, %rcx
	jb	.L5
	call	__uflow@PLT
	movq	stdin(%rip), %rdi
	movl	%eax, %edx
	leal	-48(%rdx), %ecx
	movq	8(%rdi), %rax
	movq	16(%rdi), %rsi
	cmpb	$9, %cl
	ja	.L6
	.p2align 4,,10
	.p2align 3
.L9:
	xorl	%r12d, %r12d
	jmp	.L13
	.p2align 4,,10
	.p2align 3
.L10:
	leaq	1(%rax), %rdx
	movq	%rdx, 8(%rdi)
	movzbl	(%rax), %edx
	leal	-48(%rdx), %eax
	cmpb	$9, %al
	ja	.L1
.L11:
	movq	8(%rdi), %rax
	movq	16(%rdi), %rsi
.L13:
	leal	(%r12,%r12,4), %ecx
	movsbl	%dl, %edx
	leal	-48(%rdx,%rcx,2), %r12d
	cmpq	%rsi, %rax
	jb	.L10
	call	__uflow@PLT
	movl	%eax, %edx
	subl	$48, %eax
	cmpb	$9, %al
	ja	.L1
	movq	stdin(%rip), %rdi
	jmp	.L11
	.p2align 4,,10
	.p2align 3
.L1:
	movl	%r12d, %eax
	popq	%r12
	.cfi_remember_state
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L4:
	.cfi_restore_state
	movq	%rcx, %rax
	jmp	.L9
	.p2align 4,,10
	.p2align 3
.L17:
	call	__uflow@PLT
	movq	stdin(%rip), %rdi
	movl	%eax, %edx
	movq	8(%rdi), %rcx
	movq	16(%rdi), %rsi
	jmp	.L3
	.cfi_endproc
.LFE63:
	.size	nextpint, .-nextpint
	.p2align 4
	.globl	nextplong
	.type	nextplong, @function
nextplong:
.LFB64:
	.cfi_startproc
	endbr64
	movq	stdin(%rip), %rdi
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	movq	8(%rdi), %rax
	movq	16(%rdi), %rsi
	cmpq	%rsi, %rax
	jnb	.L33
	leaq	1(%rax), %rcx
	movq	%rcx, 8(%rdi)
	movzbl	(%rax), %edx
	movl	%edx, %eax
.L20:
	subl	$48, %eax
	cmpb	$9, %al
	ja	.L25
	jmp	.L21
	.p2align 4,,10
	.p2align 3
.L22:
	leaq	1(%rcx), %rax
	movq	%rax, 8(%rdi)
	movzbl	(%rcx), %edx
	movl	%edx, %ecx
	subl	$48, %ecx
	cmpb	$9, %cl
	jbe	.L26
.L23:
	movq	%rax, %rcx
.L25:
	cmpq	%rsi, %rcx
	jb	.L22
	call	__uflow@PLT
	movq	stdin(%rip), %rdi
	movl	%eax, %edx
	leal	-48(%rdx), %ecx
	movq	8(%rdi), %rax
	movq	16(%rdi), %rsi
	cmpb	$9, %cl
	ja	.L23
	.p2align 4,,10
	.p2align 3
.L26:
	xorl	%r12d, %r12d
	jmp	.L30
	.p2align 4,,10
	.p2align 3
.L27:
	leaq	1(%rax), %rdx
	movq	%rdx, 8(%rdi)
	movzbl	(%rax), %edx
	leal	-48(%rdx), %eax
	cmpb	$9, %al
	ja	.L18
.L28:
	movq	8(%rdi), %rax
	movq	16(%rdi), %rsi
.L30:
	leaq	(%r12,%r12,4), %rcx
	movsbq	%dl, %rdx
	leaq	-48(%rdx,%rcx,2), %r12
	cmpq	%rsi, %rax
	jb	.L27
	call	__uflow@PLT
	movl	%eax, %edx
	subl	$48, %eax
	cmpb	$9, %al
	ja	.L18
	movq	stdin(%rip), %rdi
	jmp	.L28
	.p2align 4,,10
	.p2align 3
.L18:
	movq	%r12, %rax
	popq	%r12
	.cfi_remember_state
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L21:
	.cfi_restore_state
	movq	%rcx, %rax
	jmp	.L26
	.p2align 4,,10
	.p2align 3
.L33:
	call	__uflow@PLT
	movq	stdin(%rip), %rdi
	movl	%eax, %edx
	movq	8(%rdi), %rcx
	movq	16(%rdi), %rsi
	jmp	.L20
	.cfi_endproc
.LFE64:
	.size	nextplong, .-nextplong
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%u\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB65:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	leaq	a(%rip), %r12
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	movl	$1, %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	subq	$8, %rsp
	.cfi_def_cfa_offset 48
	call	nextpint
	movl	%eax, %r13d
	call	nextplong
	movq	%rax, %rbx
	testl	%r13d, %r13d
	je	.L38
	.p2align 4,,10
	.p2align 3
.L35:
	call	nextpint
	movl	%eax, (%r12,%rbp,4)
	addq	$1, %rbp
	cmpl	%ebp, %r13d
	jnb	.L35
.L38:
	leaq	a(%rip), %r12
	movl	$1, %ecx
	leaq	s(%rip), %rdx
	movl	$1, %r8d
	testq	%rbx, %rbx
	jne	.L36
	jmp	.L37
	.p2align 4,,10
	.p2align 3
.L53:
	movl	%edi, (%rdx,%rcx,4)
	testq	%rbx, %rbx
	je	.L37
.L36:
	movl	(%r12,%rcx,4), %ecx
	movl	%ebx, %edi
	subq	$1, %rbx
	movl	(%rdx,%rcx,4), %eax
	movq	%rcx, %r8
	testl	%eax, %eax
	je	.L53
	movl	%eax, %esi
	xorl	%edx, %edx
	movq	%rbx, %rax
	subl	%edi, %esi
	divq	%rsi
	testq	%rdx, %rdx
	jne	.L40
	jmp	.L37
	.p2align 4,,10
	.p2align 3
.L54:
	movl	%r8d, %ecx
.L40:
	movl	(%r12,%rcx,4), %r8d
	subq	$1, %rdx
	jne	.L54
.L37:
	movl	%r8d, %edx
	leaq	.LC0(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	addq	$8, %rsp
	.cfi_def_cfa_offset 40
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%rbp
	.cfi_def_cfa_offset 24
	popq	%r12
	.cfi_def_cfa_offset 16
	popq	%r13
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE65:
	.size	main, .-main
	.globl	s
	.bss
	.align 32
	.type	s, @object
	.size	s, 800004
s:
	.zero	800004
	.globl	a
	.align 32
	.type	a, @object
	.size	a, 800004
a:
	.zero	800004
	.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 <float.h>
#include <inttypes.h>
#include <limits.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <math.h>
#ifdef __cplusplus
#include <bits/stdc++.h>
#endif

uint32_t nextpint(void){ char c=getchar_unlocked(); while(c<'0'||'9'<c) c=getchar_unlocked(); uint32_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar_unlocked(); } return x; }
uint64_t nextplong(void){ char c=getchar_unlocked(); while(c<'0'||'9'<c) c=getchar_unlocked(); uint64_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar_unlocked(); } return x; }

uint32_t a[200001];
uint32_t s[200001];
int main(void){
	uint32_t n=nextpint();
	uint64_t k=nextplong();
	for(uint32_t i=1; i<=n; i++){
		a[i]=nextpint();
	}
	uint32_t now=1;
	for(; k>0; k--){
		now = a[now];
		if(s[now]==0){
			s[now]=k;
		}else{
			uint32_t m=s[now]-k;
			k=(k-1)%m;
			break;
		}
	}
	for(; k>0; k--){
		now = a[now];
	}
	printf("%"PRIu32"\n", now);
}

6 727202214173249351
6 5 1 5 3 2
 4 9
3 2 4 1
 6 1007784494318310970
6 5 2 5 3 2
 6 237500909755776657
6 4 1 5 3 2
 6 727202214173249351
4 5 2 5 3 2
 6 165759462200935729
4 5 2 5 3 2
 6 727202214173249351
6 4 1 5 3 2
 4 0
3 2 4 1
 6 727202214173249351
6 4 1 1 3 2
 6 237500909755776657
2 4 1 5 3 2

6
 1
 3
 4
 5
 2
 3
 1
 4
 4

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

```c
#include <float.h>
#include <inttypes.h>
#include <limits.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <math.h>
#ifdef __cplusplus
#include <bits/stdc++.h>
#endif

uint32_t nextpint(void){ char c=getchar_unlocked(); while(c<'0'||'9'<c) c=getchar_unlocked(); uint32_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar_unlocked(); } return x; }
uint64_t nextplong(void){ char c=getchar_unlocked(); while(c<'0'||'9'<c) c=getchar_unlocked(); uint64_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar_unlocked(); } return x; }

uint32_t a[200001];
uint32_t s[200001];
int main(void){
	uint32_t n=nextpint();
	uint64_t k=nextplong();
	for(uint32_t i=1; i<=n; i++){
		a[i]=nextpint();
	}
	uint32_t now=1;
	for(; k>0; k--){
		now = a[now];
		if(s[now]==0){
			s[now]=k;
		}else{
			uint32_t m=s[now]-k;
			k=(k-1)%m;
			break;
		}
	}
	for(; k>0; k--){
		now = a[now];
	}
	printf("%"PRIu32"\n", now);
}
```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	nextpint
	.type	nextpint, @function
nextpint:
.LFB6:
	.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
	call	getchar_unlocked@PLT
	movb	%al, -5(%rbp)
	jmp	.L2
.L3:
	call	getchar_unlocked@PLT
	movb	%al, -5(%rbp)
.L2:
	cmpb	$47, -5(%rbp)
	jle	.L3
	cmpb	$57, -5(%rbp)
	jg	.L3
	movl	$0, -4(%rbp)
	jmp	.L4
.L6:
	movl	-4(%rbp), %edx
	movl	%edx, %eax
	sall	$2, %eax
	addl	%edx, %eax
	addl	%eax, %eax
	movl	%eax, %edx
	movsbl	-5(%rbp), %eax
	addl	%edx, %eax
	subl	$48, %eax
	movl	%eax, -4(%rbp)
	call	getchar_unlocked@PLT
	movb	%al, -5(%rbp)
.L4:
	cmpb	$47, -5(%rbp)
	jle	.L5
	cmpb	$57, -5(%rbp)
	jle	.L6
.L5:
	movl	-4(%rbp), %eax
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	nextpint, .-nextpint
	.globl	nextplong
	.type	nextplong, @function
nextplong:
.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
	call	getchar_unlocked@PLT
	movb	%al, -9(%rbp)
	jmp	.L9
.L10:
	call	getchar_unlocked@PLT
	movb	%al, -9(%rbp)
.L9:
	cmpb	$47, -9(%rbp)
	jle	.L10
	cmpb	$57, -9(%rbp)
	jg	.L10
	movq	$0, -8(%rbp)
	jmp	.L11
.L13:
	movq	-8(%rbp), %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rax, %rax
	movq	%rax, %rdx
	movsbq	-9(%rbp), %rax
	addq	%rdx, %rax
	subq	$48, %rax
	movq	%rax, -8(%rbp)
	call	getchar_unlocked@PLT
	movb	%al, -9(%rbp)
.L11:
	cmpb	$47, -9(%rbp)
	jle	.L12
	cmpb	$57, -9(%rbp)
	jle	.L13
.L12:
	movq	-8(%rbp), %rax
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.size	nextplong, .-nextplong
	.globl	a
	.bss
	.align 32
	.type	a, @object
	.size	a, 800004
a:
	.zero	800004
	.globl	s
	.align 32
	.type	s, @object
	.size	s, 800004
s:
	.zero	800004
	.section	.rodata
.LC0:
	.string	"%u\n"
	.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	$32, %rsp
	call	nextpint
	movl	%eax, -16(%rbp)
	call	nextplong
	movq	%rax, -8(%rbp)
	movl	$1, -24(%rbp)
	jmp	.L16
.L17:
	call	nextpint
	movl	-24(%rbp), %edx
	leaq	0(,%rdx,4), %rcx
	leaq	a(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	addl	$1, -24(%rbp)
.L16:
	movl	-24(%rbp), %eax
	cmpl	-16(%rbp), %eax
	jbe	.L17
	movl	$1, -20(%rbp)
	jmp	.L18
.L22:
	movl	-20(%rbp), %eax
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -20(%rbp)
	movl	-20(%rbp), %eax
	leaq	0(,%rax,4), %rdx
	leaq	s(%rip), %rax
	movl	(%rdx,%rax), %eax
	testl	%eax, %eax
	jne	.L19
	movq	-8(%rbp), %rax
	movl	%eax, %ecx
	movl	-20(%rbp), %eax
	leaq	0(,%rax,4), %rdx
	leaq	s(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	jmp	.L26
.L19:
	movl	-20(%rbp), %eax
	leaq	0(,%rax,4), %rdx
	leaq	s(%rip), %rax
	movl	(%rdx,%rax), %eax
	movq	-8(%rbp), %rdx
	subl	%edx, %eax
	movl	%eax, -12(%rbp)
	movq	-8(%rbp), %rax
	subq	$1, %rax
	movl	-12(%rbp), %ecx
	movl	$0, %edx
	divq	%rcx
	movq	%rdx, -8(%rbp)
	jmp	.L21
.L26:
	subq	$1, -8(%rbp)
.L18:
	cmpq	$0, -8(%rbp)
	jne	.L22
.L21:
	jmp	.L23
.L24:
	movl	-20(%rbp), %eax
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -20(%rbp)
	subq	$1, -8(%rbp)
.L23:
	cmpq	$0, -8(%rbp)
	jne	.L24
	movl	-20(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	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	nextpint
	.type	nextpint, @function
nextpint:
.LFB6:
	.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
	call	getchar_unlocked@PLT
	movb	%al, -5(%rbp)
	jmp	.L2
.L3:
	call	getchar_unlocked@PLT
	movb	%al, -5(%rbp)
.L2:
	cmpb	$47, -5(%rbp)
	jle	.L3
	cmpb	$57, -5(%rbp)
	jg	.L3
	movl	$0, -4(%rbp)
	jmp	.L4
.L6:
	movl	-4(%rbp), %edx
	movl	%edx, %eax
	sall	$2, %eax
	addl	%edx, %eax
	addl	%eax, %eax
	movl	%eax, %edx
	movsbl	-5(%rbp), %eax
	addl	%edx, %eax
	subl	$48, %eax
	movl	%eax, -4(%rbp)
	call	getchar_unlocked@PLT
	movb	%al, -5(%rbp)
.L4:
	cmpb	$47, -5(%rbp)
	jle	.L5
	cmpb	$57, -5(%rbp)
	jle	.L6
.L5:
	movl	-4(%rbp), %eax
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	nextpint, .-nextpint
	.globl	nextplong
	.type	nextplong, @function
nextplong:
.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
	call	getchar_unlocked@PLT
	movb	%al, -9(%rbp)
	jmp	.L9
.L10:
	call	getchar_unlocked@PLT
	movb	%al, -9(%rbp)
.L9:
	cmpb	$47, -9(%rbp)
	jle	.L10
	cmpb	$57, -9(%rbp)
	jg	.L10
	movq	$0, -8(%rbp)
	jmp	.L11
.L13:
	movq	-8(%rbp), %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rax, %rax
	movq	%rax, %rdx
	movsbq	-9(%rbp), %rax
	addq	%rdx, %rax
	subq	$48, %rax
	movq	%rax, -8(%rbp)
	call	getchar_unlocked@PLT
	movb	%al, -9(%rbp)
.L11:
	cmpb	$47, -9(%rbp)
	jle	.L12
	cmpb	$57, -9(%rbp)
	jle	.L13
.L12:
	movq	-8(%rbp), %rax
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.size	nextplong, .-nextplong
	.globl	a
	.bss
	.align 32
	.type	a, @object
	.size	a, 800004
a:
	.zero	800004
	.globl	s
	.align 32
	.type	s, @object
	.size	s, 800004
s:
	.zero	800004
	.section	.rodata
.LC0:
	.string	"%u\n"
	.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	$32, %rsp
	call	nextpint
	movl	%eax, -16(%rbp)
	call	nextplong
	movq	%rax, -8(%rbp)
	movl	$1, -24(%rbp)
	jmp	.L16
.L17:
	call	nextpint
	movl	-24(%rbp), %edx
	leaq	0(,%rdx,4), %rcx
	leaq	a(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	addl	$1, -24(%rbp)
.L16:
	movl	-24(%rbp), %eax
	cmpl	-16(%rbp), %eax
	jbe	.L17
	movl	$1, -20(%rbp)
	jmp	.L18
.L22:
	movl	-20(%rbp), %eax
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -20(%rbp)
	movl	-20(%rbp), %eax
	leaq	0(,%rax,4), %rdx
	leaq	s(%rip), %rax
	movl	(%rdx,%rax), %eax
	testl	%eax, %eax
	jne	.L19
	movq	-8(%rbp), %rax
	movl	%eax, %ecx
	movl	-20(%rbp), %eax
	leaq	0(,%rax,4), %rdx
	leaq	s(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	jmp	.L26
.L19:
	movl	-20(%rbp), %eax
	leaq	0(,%rax,4), %rdx
	leaq	s(%rip), %rax
	movl	(%rdx,%rax), %eax
	movq	-8(%rbp), %rdx
	subl	%edx, %eax
	movl	%eax, -12(%rbp)
	movq	-8(%rbp), %rax
	subq	$1, %rax
	movl	-12(%rbp), %ecx
	movl	$0, %edx
	divq	%rcx
	movq	%rdx, -8(%rbp)
	jmp	.L21
.L26:
	subq	$1, -8(%rbp)
.L18:
	cmpq	$0, -8(%rbp)
	jne	.L22
.L21:
	jmp	.L23
.L24:
	movl	-20(%rbp), %eax
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -20(%rbp)
	subq	$1, -8(%rbp)
.L23:
	cmpq	$0, -8(%rbp)
	jne	.L24
	movl	-20(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	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:
