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>

int main()
{
	int i,j;
	int N;
	long K;
	int *A;
	int *s;
	int sindex;
	int circ, leng;
	int *ord;
	int temp;
	int v;
	int ret;
	
	ret = scanf("%d %ld", &N, &K);
	A = (int *)malloc(sizeof(int)*N);
	s = (int *)malloc(sizeof(int)*N);
	ord = (int *)malloc(sizeof(int)*(N+1));
	for (i =0; i < N+1; i++) {
		ord[i] = -1;
	}
	
	for (i =0; i < N; i++) {
		ret =scanf(" %d", &A[i]);
	}

	v = 1;
	sindex=0;
	circ = 0;
	leng = 0;
	while (ord[v] == -1) {
		ord[v] = sindex;
		s[sindex++] = v;
		v = A[v-1];
	}
	circ = sindex - ord[v];
	leng = ord[v];

	if (K < leng) {
		printf("%d\n", s[K]);
	} else {
		K -= leng;
		K %= circ;
		printf("%d\n", s[leng+K]);
	}


	free(A);
	free(s);
	free(ord);
	return EXIT_SUCCESS;
}
```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%d %ld"
.LC1:
	.string	" %d"
.LC2:
	.string	"%d\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
	subq	$80, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-40(%rbp), %rdx
	leaq	-68(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	%eax, -52(%rbp)
	movl	-68(%rbp), %eax
	cltq
	salq	$2, %rax
	movq	%rax, %rdi
	call	malloc@PLT
	movq	%rax, -32(%rbp)
	movl	-68(%rbp), %eax
	cltq
	salq	$2, %rax
	movq	%rax, %rdi
	call	malloc@PLT
	movq	%rax, -24(%rbp)
	movl	-68(%rbp), %eax
	addl	$1, %eax
	cltq
	salq	$2, %rax
	movq	%rax, %rdi
	call	malloc@PLT
	movq	%rax, -16(%rbp)
	movl	$0, -64(%rbp)
	jmp	.L2
.L3:
	movl	-64(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movl	$-1, (%rax)
	addl	$1, -64(%rbp)
.L2:
	movl	-68(%rbp), %eax
	cmpl	%eax, -64(%rbp)
	jle	.L3
	movl	$0, -64(%rbp)
	jmp	.L4
.L5:
	movl	-64(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-32(%rbp), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	%eax, -52(%rbp)
	addl	$1, -64(%rbp)
.L4:
	movl	-68(%rbp), %eax
	cmpl	%eax, -64(%rbp)
	jl	.L5
	movl	$1, -56(%rbp)
	movl	$0, -60(%rbp)
	movl	$0, -48(%rbp)
	movl	$0, -44(%rbp)
	jmp	.L6
.L7:
	movl	-56(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-16(%rbp), %rax
	addq	%rax, %rdx
	movl	-60(%rbp), %eax
	movl	%eax, (%rdx)
	movl	-60(%rbp), %eax
	leal	1(%rax), %edx
	movl	%edx, -60(%rbp)
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rax, %rdx
	movl	-56(%rbp), %eax
	movl	%eax, (%rdx)
	movl	-56(%rbp), %eax
	cltq
	salq	$2, %rax
	leaq	-4(%rax), %rdx
	movq	-32(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	movl	%eax, -56(%rbp)
.L6:
	movl	-56(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	cmpl	$-1, %eax
	je	.L7
	movl	-56(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %edx
	movl	-60(%rbp), %eax
	subl	%edx, %eax
	movl	%eax, -48(%rbp)
	movl	-56(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	movl	%eax, -44(%rbp)
	movl	-44(%rbp), %eax
	movslq	%eax, %rdx
	movq	-40(%rbp), %rax
	cmpq	%rax, %rdx
	jle	.L8
	movq	-40(%rbp), %rax
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L9
.L8:
	movq	-40(%rbp), %rax
	movl	-44(%rbp), %edx
	movslq	%edx, %rdx
	subq	%rdx, %rax
	movq	%rax, -40(%rbp)
	movq	-40(%rbp), %rax
	movl	-48(%rbp), %edx
	movslq	%edx, %rcx
	cqto
	idivq	%rcx
	movq	%rdx, %rax
	movq	%rax, -40(%rbp)
	movl	-44(%rbp), %eax
	movslq	%eax, %rdx
	movq	-40(%rbp), %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L9:
	movq	-32(%rbp), %rax
	movq	%rax, %rdi
	call	free@PLT
	movq	-24(%rbp), %rax
	movq	%rax, %rdi
	call	free@PLT
	movq	-16(%rbp), %rax
	movq	%rax, %rdi
	call	free@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
.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	"%d %ld"
.LC1:
	.string	" %d"
.LC2:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB39:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	leaq	.LC0(%rip), %rdi
	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	$40, %rsp
	.cfi_def_cfa_offset 96
	movq	%fs:40, %rax
	movq	%rax, 24(%rsp)
	xorl	%eax, %eax
	leaq	16(%rsp), %rdx
	leaq	12(%rsp), %rsi
	call	__isoc99_scanf@PLT
	movslq	12(%rsp), %r15
	leaq	0(,%r15,4), %rbx
	movq	%rbx, %rdi
	call	malloc@PLT
	movq	%rbx, %rdi
	movq	%rax, %r12
	call	malloc@PLT
	leaq	4(%rbx), %rdi
	movq	%rax, %r13
	call	malloc@PLT
	movq	%rax, %rbp
	testl	%r15d, %r15d
	js	.L2
	leaq	4(,%r15,4), %rdx
	movl	$255, %esi
	movq	%rax, %rdi
	call	memset@PLT
	testl	%r15d, %r15d
	jle	.L2
	movq	%r12, %r14
	xorl	%ebx, %ebx
	leaq	.LC1(%rip), %r15
	.p2align 4,,10
	.p2align 3
.L3:
	movq	%r14, %rsi
	movq	%r15, %rdi
	xorl	%eax, %eax
	addl	$1, %ebx
	call	__isoc99_scanf@PLT
	addq	$4, %r14
	cmpl	%ebx, 12(%rsp)
	jg	.L3
.L2:
	movl	4(%rbp), %r8d
	leaq	4(%rbp), %rcx
	cmpl	$-1, %r8d
	jne	.L9
	movq	%r13, %rdi
	movl	$1, %esi
	xorl	%edx, %edx
	movl	$4, %eax
	.p2align 4,,10
	.p2align 3
.L5:
	movslq	-4(%r12,%rax), %rax
	movl	%esi, (%rdi)
	addq	$4, %rdi
	movl	%edx, (%rcx)
	addl	$1, %edx
	movq	%rax, %rsi
	salq	$2, %rax
	leaq	0(%rbp,%rax), %rcx
	movl	(%rcx), %r8d
	cmpl	$-1, %r8d
	je	.L5
.L4:
	movq	16(%rsp), %rax
	movslq	%r8d, %rsi
	cmpq	%rax, %rsi
	jle	.L6
	movl	0(%r13,%rax,4), %edx
	leaq	.LC2(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L7:
	movq	%r12, %rdi
	call	free@PLT
	movq	%r13, %rdi
	call	free@PLT
	movq	%rbp, %rdi
	call	free@PLT
	movq	24(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L15
	addq	$40, %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
.L6:
	.cfi_restore_state
	subq	%rsi, %rax
	subl	%r8d, %edx
	movl	$1, %edi
	movslq	%edx, %rcx
	cqto
	idivq	%rcx
	xorl	%eax, %eax
	addq	%rdx, %rsi
	movq	%rdx, 16(%rsp)
	movl	0(%r13,%rsi,4), %edx
	leaq	.LC2(%rip), %rsi
	call	__printf_chk@PLT
	jmp	.L7
.L9:
	xorl	%edx, %edx
	jmp	.L4
.L15:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE39:
	.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	"%d %ld"
.LC1:
	.string	" %d"
.LC2:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB39:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	leaq	.LC0(%rip), %rdi
	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	$40, %rsp
	.cfi_def_cfa_offset 96
	movq	%fs:40, %rax
	movq	%rax, 24(%rsp)
	xorl	%eax, %eax
	leaq	16(%rsp), %rdx
	leaq	12(%rsp), %rsi
	call	__isoc99_scanf@PLT
	movslq	12(%rsp), %r15
	leaq	0(,%r15,4), %rbx
	movq	%rbx, %rdi
	call	malloc@PLT
	movq	%rbx, %rdi
	movq	%rax, %r12
	call	malloc@PLT
	leaq	4(%rbx), %rdi
	movq	%rax, %r13
	call	malloc@PLT
	movq	%rax, %rbp
	testl	%r15d, %r15d
	js	.L2
	leaq	4(,%r15,4), %rdx
	movl	$255, %esi
	movq	%rax, %rdi
	call	memset@PLT
	testl	%r15d, %r15d
	jle	.L2
	movq	%r12, %r14
	xorl	%ebx, %ebx
	leaq	.LC1(%rip), %r15
	.p2align 4,,10
	.p2align 3
.L3:
	movq	%r14, %rsi
	movq	%r15, %rdi
	xorl	%eax, %eax
	addl	$1, %ebx
	call	__isoc99_scanf@PLT
	addq	$4, %r14
	cmpl	%ebx, 12(%rsp)
	jg	.L3
.L2:
	movl	4(%rbp), %r8d
	leaq	4(%rbp), %rcx
	cmpl	$-1, %r8d
	jne	.L9
	movq	%r13, %rdi
	movl	$1, %esi
	xorl	%edx, %edx
	movl	$4, %eax
	.p2align 4,,10
	.p2align 3
.L5:
	movslq	-4(%r12,%rax), %rax
	movl	%esi, (%rdi)
	addq	$4, %rdi
	movl	%edx, (%rcx)
	addl	$1, %edx
	movq	%rax, %rsi
	salq	$2, %rax
	leaq	0(%rbp,%rax), %rcx
	movl	(%rcx), %r8d
	cmpl	$-1, %r8d
	je	.L5
.L4:
	movq	16(%rsp), %rax
	movslq	%r8d, %rsi
	cmpq	%rax, %rsi
	jle	.L6
	movl	0(%r13,%rax,4), %edx
	leaq	.LC2(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L7:
	movq	%r12, %rdi
	call	free@PLT
	movq	%r13, %rdi
	call	free@PLT
	movq	%rbp, %rdi
	call	free@PLT
	movq	24(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L15
	addq	$40, %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
.L6:
	.cfi_restore_state
	subq	%rsi, %rax
	subl	%r8d, %edx
	movl	$1, %edi
	movslq	%edx, %rcx
	cqto
	idivq	%rcx
	xorl	%eax, %eax
	addq	%rdx, %rsi
	movq	%rdx, 16(%rsp)
	movl	0(%r13,%rsi,4), %edx
	leaq	.LC2(%rip), %rsi
	call	__printf_chk@PLT
	jmp	.L7
.L9:
	xorl	%edx, %edx
	jmp	.L4
.L15:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE39:
	.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>

int main()
{
	int i,j;
	int N;
	long K;
	int *A;
	int *s;
	int sindex;
	int circ, leng;
	int *ord;
	int temp;
	int v;
	int ret;
	
	ret = scanf("%d %ld", &N, &K);
	A = (int *)malloc(sizeof(int)*N);
	s = (int *)malloc(sizeof(int)*N);
	ord = (int *)malloc(sizeof(int)*(N+1));
	for (i =0; i < N+1; i++) {
		ord[i] = -1;
	}
	
	for (i =0; i < N; i++) {
		ret =scanf(" %d", &A[i]);
	}

	v = 1;
	sindex=0;
	circ = 0;
	leng = 0;
	while (ord[v] == -1) {
		ord[v] = sindex;
		s[sindex++] = v;
		v = A[v-1];
	}
	circ = sindex - ord[v];
	leng = ord[v];

	if (K < leng) {
		printf("%d\n", s[K]);
	} else {
		K -= leng;
		K %= circ;
		printf("%d\n", s[leng+K]);
	}


	free(A);
	free(s);
	free(ord);
	return EXIT_SUCCESS;
}

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

int main()
{
	int i,j;
	int N;
	long K;
	int *A;
	int *s;
	int sindex;
	int circ, leng;
	int *ord;
	int temp;
	int v;
	int ret;
	
	ret = scanf("%d %ld", &N, &K);
	A = (int *)malloc(sizeof(int)*N);
	s = (int *)malloc(sizeof(int)*N);
	ord = (int *)malloc(sizeof(int)*(N+1));
	for (i =0; i < N+1; i++) {
		ord[i] = -1;
	}
	
	for (i =0; i < N; i++) {
		ret =scanf(" %d", &A[i]);
	}

	v = 1;
	sindex=0;
	circ = 0;
	leng = 0;
	while (ord[v] == -1) {
		ord[v] = sindex;
		s[sindex++] = v;
		v = A[v-1];
	}
	circ = sindex - ord[v];
	leng = ord[v];

	if (K < leng) {
		printf("%d\n", s[K]);
	} else {
		K -= leng;
		K %= circ;
		printf("%d\n", s[leng+K]);
	}


	free(A);
	free(s);
	free(ord);
	return EXIT_SUCCESS;
}
```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%d %ld"
.LC1:
	.string	" %d"
.LC2:
	.string	"%d\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
	subq	$80, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-40(%rbp), %rdx
	leaq	-68(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	%eax, -52(%rbp)
	movl	-68(%rbp), %eax
	cltq
	salq	$2, %rax
	movq	%rax, %rdi
	call	malloc@PLT
	movq	%rax, -32(%rbp)
	movl	-68(%rbp), %eax
	cltq
	salq	$2, %rax
	movq	%rax, %rdi
	call	malloc@PLT
	movq	%rax, -24(%rbp)
	movl	-68(%rbp), %eax
	addl	$1, %eax
	cltq
	salq	$2, %rax
	movq	%rax, %rdi
	call	malloc@PLT
	movq	%rax, -16(%rbp)
	movl	$0, -64(%rbp)
	jmp	.L2
.L3:
	movl	-64(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movl	$-1, (%rax)
	addl	$1, -64(%rbp)
.L2:
	movl	-68(%rbp), %eax
	cmpl	%eax, -64(%rbp)
	jle	.L3
	movl	$0, -64(%rbp)
	jmp	.L4
.L5:
	movl	-64(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-32(%rbp), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	%eax, -52(%rbp)
	addl	$1, -64(%rbp)
.L4:
	movl	-68(%rbp), %eax
	cmpl	%eax, -64(%rbp)
	jl	.L5
	movl	$1, -56(%rbp)
	movl	$0, -60(%rbp)
	movl	$0, -48(%rbp)
	movl	$0, -44(%rbp)
	jmp	.L6
.L7:
	movl	-56(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-16(%rbp), %rax
	addq	%rax, %rdx
	movl	-60(%rbp), %eax
	movl	%eax, (%rdx)
	movl	-60(%rbp), %eax
	leal	1(%rax), %edx
	movl	%edx, -60(%rbp)
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rax, %rdx
	movl	-56(%rbp), %eax
	movl	%eax, (%rdx)
	movl	-56(%rbp), %eax
	cltq
	salq	$2, %rax
	leaq	-4(%rax), %rdx
	movq	-32(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	movl	%eax, -56(%rbp)
.L6:
	movl	-56(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	cmpl	$-1, %eax
	je	.L7
	movl	-56(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %edx
	movl	-60(%rbp), %eax
	subl	%edx, %eax
	movl	%eax, -48(%rbp)
	movl	-56(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	movl	%eax, -44(%rbp)
	movl	-44(%rbp), %eax
	movslq	%eax, %rdx
	movq	-40(%rbp), %rax
	cmpq	%rax, %rdx
	jle	.L8
	movq	-40(%rbp), %rax
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L9
.L8:
	movq	-40(%rbp), %rax
	movl	-44(%rbp), %edx
	movslq	%edx, %rdx
	subq	%rdx, %rax
	movq	%rax, -40(%rbp)
	movq	-40(%rbp), %rax
	movl	-48(%rbp), %edx
	movslq	%edx, %rcx
	cqto
	idivq	%rcx
	movq	%rdx, %rax
	movq	%rax, -40(%rbp)
	movl	-44(%rbp), %eax
	movslq	%eax, %rdx
	movq	-40(%rbp), %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L9:
	movq	-32(%rbp), %rax
	movq	%rax, %rdi
	call	free@PLT
	movq	-24(%rbp), %rax
	movq	%rax, %rdi
	call	free@PLT
	movq	-16(%rbp), %rax
	movq	%rax, %rdi
	call	free@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
.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	"%d %ld"
.LC1:
	.string	" %d"
.LC2:
	.string	"%d\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
	subq	$80, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-40(%rbp), %rdx
	leaq	-68(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	%eax, -52(%rbp)
	movl	-68(%rbp), %eax
	cltq
	salq	$2, %rax
	movq	%rax, %rdi
	call	malloc@PLT
	movq	%rax, -32(%rbp)
	movl	-68(%rbp), %eax
	cltq
	salq	$2, %rax
	movq	%rax, %rdi
	call	malloc@PLT
	movq	%rax, -24(%rbp)
	movl	-68(%rbp), %eax
	addl	$1, %eax
	cltq
	salq	$2, %rax
	movq	%rax, %rdi
	call	malloc@PLT
	movq	%rax, -16(%rbp)
	movl	$0, -64(%rbp)
	jmp	.L2
.L3:
	movl	-64(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movl	$-1, (%rax)
	addl	$1, -64(%rbp)
.L2:
	movl	-68(%rbp), %eax
	cmpl	%eax, -64(%rbp)
	jle	.L3
	movl	$0, -64(%rbp)
	jmp	.L4
.L5:
	movl	-64(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-32(%rbp), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	%eax, -52(%rbp)
	addl	$1, -64(%rbp)
.L4:
	movl	-68(%rbp), %eax
	cmpl	%eax, -64(%rbp)
	jl	.L5
	movl	$1, -56(%rbp)
	movl	$0, -60(%rbp)
	movl	$0, -48(%rbp)
	movl	$0, -44(%rbp)
	jmp	.L6
.L7:
	movl	-56(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-16(%rbp), %rax
	addq	%rax, %rdx
	movl	-60(%rbp), %eax
	movl	%eax, (%rdx)
	movl	-60(%rbp), %eax
	leal	1(%rax), %edx
	movl	%edx, -60(%rbp)
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rax, %rdx
	movl	-56(%rbp), %eax
	movl	%eax, (%rdx)
	movl	-56(%rbp), %eax
	cltq
	salq	$2, %rax
	leaq	-4(%rax), %rdx
	movq	-32(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	movl	%eax, -56(%rbp)
.L6:
	movl	-56(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	cmpl	$-1, %eax
	je	.L7
	movl	-56(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %edx
	movl	-60(%rbp), %eax
	subl	%edx, %eax
	movl	%eax, -48(%rbp)
	movl	-56(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	movl	%eax, -44(%rbp)
	movl	-44(%rbp), %eax
	movslq	%eax, %rdx
	movq	-40(%rbp), %rax
	cmpq	%rax, %rdx
	jle	.L8
	movq	-40(%rbp), %rax
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L9
.L8:
	movq	-40(%rbp), %rax
	movl	-44(%rbp), %edx
	movslq	%edx, %rdx
	subq	%rdx, %rax
	movq	%rax, -40(%rbp)
	movq	-40(%rbp), %rax
	movl	-48(%rbp), %edx
	movslq	%edx, %rcx
	cqto
	idivq	%rcx
	movq	%rdx, %rax
	movq	%rax, -40(%rbp)
	movl	-44(%rbp), %eax
	movslq	%eax, %rdx
	movq	-40(%rbp), %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L9:
	movq	-32(%rbp), %rax
	movq	%rax, %rdi
	call	free@PLT
	movq	-24(%rbp), %rax
	movq	%rax, %rdi
	call	free@PLT
	movq	-16(%rbp), %rax
	movq	%rax, %rdi
	call	free@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
.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:
