Given the following C code and 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 q;
	int *a;
	int x,y,com;
	int right,left;
	
	scanf("%d",&q);
	a=malloc(sizeof(int)*2*q);
	left=q-1;
	right=q;
	
	
	for(int i=0;i<q;i++){
	
		scanf("%d",&com);
		
		if(com==0){
			scanf("%d %d",&x,&y);
			if(x)a[right++]=y;
			else a[left--]=y;
		}
		
		if(com==1){
			scanf("%d",&x);
			printf("%d\n",a[left+x+1]);
		}
		
		if(com==2){
			scanf("%d",&x);
			if(x)a[right--]=-1;
			else a[left++]=-1;
		}
		
	}
	
	return 0;
	
}
```

Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d"
.LC1:
	.string	"%d %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
	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
	leaq	.LC0(%rip), %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	movq	%rbp, %rdi
	subq	$56, %rsp
	.cfi_def_cfa_offset 112
	movq	%fs:40, %rax
	movq	%rax, 40(%rsp)
	xorl	%eax, %eax
	leaq	24(%rsp), %rsi
	call	__isoc99_scanf@PLT
	movslq	24(%rsp), %rdi
	movq	%rdi, %r12
	salq	$3, %rdi
	call	malloc@PLT
	movq	%rax, (%rsp)
	leaq	32(%rsp), %rax
	movq	%rax, 8(%rsp)
	testl	%r12d, %r12d
	jle	.L8
	leal	-1(%r12), %r14d
	xorl	%ebx, %ebx
	leaq	36(%rsp), %r13
	leaq	28(%rsp), %r15
	jmp	.L2
	.p2align 4,,10
	.p2align 3
.L3:
	cmpl	$1, %eax
	je	.L17
.L5:
	cmpl	$2, %eax
	je	.L18
.L6:
	addl	$1, %ebx
	cmpl	%ebx, 24(%rsp)
	jle	.L8
.L2:
	movq	%r13, %rsi
	movq	%rbp, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	36(%rsp), %eax
	testl	%eax, %eax
	jne	.L3
	movq	8(%rsp), %rdx
	movq	%r15, %rsi
	leaq	.LC1(%rip), %rdi
	call	__isoc99_scanf@PLT
	movl	28(%rsp), %edx
	testl	%edx, %edx
	je	.L4
	movl	32(%rsp), %edx
	movq	(%rsp), %rcx
	movslq	%r12d, %rax
	addl	$1, %r12d
	movl	%edx, (%rcx,%rax,4)
	movl	36(%rsp), %eax
	cmpl	$1, %eax
	jne	.L5
	.p2align 4,,10
	.p2align 3
.L17:
	movq	%r15, %rsi
	movq	%rbp, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	28(%rsp), %eax
	movq	(%rsp), %rcx
	leaq	.LC2(%rip), %rsi
	movl	$1, %edi
	addl	%r14d, %eax
	cltq
	movl	4(%rcx,%rax,4), %edx
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movl	36(%rsp), %eax
	cmpl	$2, %eax
	jne	.L6
.L18:
	movq	%r15, %rsi
	movq	%rbp, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	28(%rsp), %eax
	testl	%eax, %eax
	je	.L7
	movq	(%rsp), %rcx
	movslq	%r12d, %rax
	addl	$1, %ebx
	subl	$1, %r12d
	movl	$-1, (%rcx,%rax,4)
	cmpl	%ebx, 24(%rsp)
	jg	.L2
	.p2align 4,,10
	.p2align 3
.L8:
	movq	40(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L19
	addq	$56, %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
	.p2align 4,,10
	.p2align 3
.L4:
	.cfi_restore_state
	movl	32(%rsp), %edx
	movq	(%rsp), %rcx
	movslq	%r14d, %rax
	subl	$1, %r14d
	movl	%edx, (%rcx,%rax,4)
	movl	36(%rsp), %eax
	jmp	.L3
	.p2align 4,,10
	.p2align 3
.L7:
	movq	(%rsp), %rcx
	movslq	%r14d, %rax
	addl	$1, %r14d
	movl	$-1, (%rcx,%rax,4)
	jmp	.L6
.L19:
	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:
```

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.
Optimized Assembly Code:

user
```assembly
	.file	"temp.c"
	.text
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d"
.LC1:
	.string	"%d %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
	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
	leaq	.LC0(%rip), %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	movq	%rbp, %rdi
	subq	$56, %rsp
	.cfi_def_cfa_offset 112
	movq	%fs:40, %rax
	movq	%rax, 40(%rsp)
	xorl	%eax, %eax
	leaq	24(%rsp), %rsi
	call	__isoc99_scanf@PLT
	movslq	24(%rsp), %rdi
	movq	%rdi, %r12
	salq	$3, %rdi
	call	malloc@PLT
	movq	%rax, (%rsp)
	leaq	32(%rsp), %rax
	movq	%rax, 8(%rsp)
	testl	%r12d, %r12d
	jle	.L8
	leal	-1(%r12), %r14d
	xorl	%ebx, %ebx
	leaq	36(%rsp), %r13
	leaq	28(%rsp), %r15
	jmp	.L2
	.p2align 4,,10
	.p2align 3
.L3:
	cmpl	$1, %eax
	je	.L17
.L5:
	cmpl	$2, %eax
	je	.L18
.L6:
	addl	$1, %ebx
	cmpl	%ebx, 24(%rsp)
	jle	.L8
.L2:
	movq	%r13, %rsi
	movq	%rbp, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	36(%rsp), %eax
	testl	%eax, %eax
	jne	.L3
	movq	8(%rsp), %rdx
	movq	%r15, %rsi
	leaq	.LC1(%rip), %rdi
	call	__isoc99_scanf@PLT
	movl	28(%rsp), %edx
	testl	%edx, %edx
	je	.L4
	movl	32(%rsp), %edx
	movq	(%rsp), %rcx
	movslq	%r12d, %rax
	addl	$1, %r12d
	movl	%edx, (%rcx,%rax,4)
	movl	36(%rsp), %eax
	cmpl	$1, %eax
	jne	.L5
	.p2align 4,,10
	.p2align 3
.L17:
	movq	%r15, %rsi
	movq	%rbp, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	28(%rsp), %eax
	movq	(%rsp), %rcx
	leaq	.LC2(%rip), %rsi
	movl	$1, %edi
	addl	%r14d, %eax
	cltq
	movl	4(%rcx,%rax,4), %edx
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movl	36(%rsp), %eax
	cmpl	$2, %eax
	jne	.L6
.L18:
	movq	%r15, %rsi
	movq	%rbp, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	28(%rsp), %eax
	testl	%eax, %eax
	je	.L7
	movq	(%rsp), %rcx
	movslq	%r12d, %rax
	addl	$1, %ebx
	subl	$1, %r12d
	movl	$-1, (%rcx,%rax,4)
	cmpl	%ebx, 24(%rsp)
	jg	.L2
	.p2align 4,,10
	.p2align 3
.L8:
	movq	40(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L19
	addq	$56, %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
	.p2align 4,,10
	.p2align 3
.L4:
	.cfi_restore_state
	movl	32(%rsp), %edx
	movq	(%rsp), %rcx
	movslq	%r14d, %rax
	subl	$1, %r14d
	movl	%edx, (%rcx,%rax,4)
	movl	36(%rsp), %eax
	jmp	.L3
	.p2align 4,,10
	.p2align 3
.L7:
	movq	(%rsp), %rcx
	movslq	%r14d, %rax
	addl	$1, %r14d
	movl	$-1, (%rcx,%rax,4)
	jmp	.L6
.L19:
	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
```assembly
	.file	"temp.c"
	.text
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d"
.LC1:
	.string	"%d %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
	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
	leaq	.LC0(%rip), %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	movq	%rbp, %rdi
	subq	$56, %rsp
	.cfi_def_cfa_offset 112
	movq	%fs:40, %rax
	movq	%rax, 40(%rsp)
	xorl	%eax, %eax
	leaq	24(%rsp), %rsi
	call	__isoc99_scanf@PLT
	movslq	24(%rsp), %rdi
	movq	%rdi, %r12
	salq	$3, %rdi
	call	malloc@PLT
	movq	%rax, (%rsp)
	leaq	32(%rsp), %rax
	movq	%rax, 8(%rsp)
	testl	%r12d, %r12d
	jle	.L8
	leal	-1(%r12), %r14d
	xorl	%ebx, %ebx
	leaq	36(%rsp), %r13
	leaq	28(%rsp), %r15
	jmp	.L2
	.p2align 4,,10
	.p2align 3
.L3:
	cmpl	$1, %eax
	je	.L17
.L5:
	cmpl	$2, %eax
	je	.L18
.L6:
	addl	$1, %ebx
	cmpl	%ebx, 24(%rsp)
	jle	.L8
.L2:
	movq	%r13, %rsi
	movq	%rbp, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	36(%rsp), %eax
	testl	%eax, %eax
	jne	.L3
	movq	8(%rsp), %rdx
	movq	%r15, %rsi
	leaq	.LC1(%rip), %rdi
	call	__isoc99_scanf@PLT
	movl	28(%rsp), %edx
	testl	%edx, %edx
	je	.L4
	movl	32(%rsp), %edx
	movq	(%rsp), %rcx
	movslq	%r12d, %rax
	addl	$1, %r12d
	movl	%edx, (%rcx,%rax,4)
	movl	36(%rsp), %eax
	cmpl	$1, %eax
	jne	.L5
	.p2align 4,,10
	.p2align 3
.L17:
	movq	%r15, %rsi
	movq	%rbp, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	28(%rsp), %eax
	movq	(%rsp), %rcx
	leaq	.LC2(%rip), %rsi
	movl	$1, %edi
	addl	%r14d, %eax
	cltq
	movl	4(%rcx,%rax,4), %edx
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movl	36(%rsp), %eax
	cmpl	$2, %eax
	jne	.L6
.L18:
	movq	%r15, %rsi
	movq	%rbp, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	28(%rsp), %eax
	testl	%eax, %eax
	je	.L7
	movq	(%rsp), %rcx
	movslq	%r12d, %rax
	addl	$1, %ebx
	subl	$1, %r12d
	movl	$-1, (%rcx,%rax,4)
	cmpl	%ebx, 24(%rsp)
	jg	.L2
	.p2align 4,,10
	.p2align 3
.L8:
	movq	40(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L19
	addq	$56, %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
	.p2align 4,,10
	.p2align 3
.L4:
	.cfi_restore_state
	movl	32(%rsp), %edx
	movq	(%rsp), %rcx
	movslq	%r14d, %rax
	subl	$1, %r14d
	movl	%edx, (%rcx,%rax,4)
	movl	36(%rsp), %eax
	jmp	.L3
	.p2align 4,,10
	.p2align 3
.L7:
	movq	(%rsp), %rcx
	movslq	%r14d, %rax
	addl	$1, %r14d
	movl	$-1, (%rcx,%rax,4)
	jmp	.L6
.L19:
	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:
```
```c
#include<stdio.h>
#include<stdlib.h>

int main(){
	int q;
	int *a;
	int x,y,com;
	int right,left;
	
	scanf("%d",&q);
	a=malloc(sizeof(int)*2*q);
	left=q-1;
	right=q;
	
	
	for(int i=0;i<q;i++){
	
		scanf("%d",&com);
		
		if(com==0){
			scanf("%d %d",&x,&y);
			if(x)a[right++]=y;
			else a[left--]=y;
		}
		
		if(com==1){
			scanf("%d",&x);
			printf("%d\n",a[left+x+1]);
		}
		
		if(com==2){
			scanf("%d",&x);
			if(x)a[right--]=-1;
			else a[left++]=-1;
		}
		
	}
	
	return 0;
	
}
```
Given the following C code, your task is to generate highly optimized x86-64 assembly code.
C Code:

```c
#include<stdio.h>
#include<stdlib.h>

int main(){
	int q;
	int *a;
	int x,y,com;
	int right,left;
	
	scanf("%d",&q);
	a=malloc(sizeof(int)*2*q);
	left=q-1;
	right=q;
	
	
	for(int i=0;i<q;i++){
	
		scanf("%d",&com);
		
		if(com==0){
			scanf("%d %d",&x,&y);
			if(x)a[right++]=y;
			else a[left--]=y;
		}
		
		if(com==1){
			scanf("%d",&x);
			printf("%d\n",a[left+x+1]);
		}
		
		if(com==2){
			scanf("%d",&x);
			if(x)a[right--]=-1;
			else a[left++]=-1;
		}
		
	}
	
	return 0;
	
}
```

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.
Optimized Assembly Code:

11
0 0 1
0 0 2
0 1 3
1 0
1 1
1 0
2 0
2 1
0 0 4
1 0
1 1
 11
0 0 1
0 0 2
0 1 3
1 0
1 1
1 0
2 0
2 1
0 0 4
1 0
2 1
 11
0 0 1
0 0 3
0 1 3
1 0
1 1
1 0
2 0
2 1
0 0 4
1 0
2 1
 11
0 0 1
0 0 3
0 1 3
1 0
1 1
1 0
2 0
2 1
0 0 4
2 0
2 1
 11
0 0 1
0 0 2
0 1 3
1 0
1 1
1 1
2 0
2 1
0 0 4
1 0
1 1
 11
0 0 1
0 0 2
0 1 3
1 1
1 1
1 0
2 0
2 1
0 0 4
1 0
1 1
 11
0 0 2
0 0 2
0 1 3
1 0
1 1
1 0
2 0
2 1
0 0 4
1 0
2 1
 11
0 0 1
0 0 3
0 1 3
1 0
1 1
1 0
2 0
1 1
0 0 4
1 0
2 1
 11
0 0 2
0 0 3
0 1 3
1 0
1 1
1 0
2 0
1 1
0 0 4
1 0
2 1
 11
0 0 2
0 0 2
0 1 3
1 0
1 1
1 0
2 0
2 1
0 -1 4
1 0
2 1

2
1
2
4
1
 2
1
2
4
 3
1
3
4
 3
1
3
 2
1
1
4
1
 1
1
2
4
1
 2
2
2
4
 3
1
3
3
4
 3
2
3
3
4
 2
2
2
2

Given the following C code and 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 q;
	int *a;
	int x,y,com;
	int right,left;
	
	scanf("%d",&q);
	a=malloc(sizeof(int)*2*q);
	left=q-1;
	right=q;
	
	
	for(int i=0;i<q;i++){
	
		scanf("%d",&com);
		
		if(com==0){
			scanf("%d %d",&x,&y);
			if(x)a[right++]=y;
			else a[left--]=y;
		}
		
		if(com==1){
			scanf("%d",&x);
			printf("%d\n",a[left+x+1]);
		}
		
		if(com==2){
			scanf("%d",&x);
			if(x)a[right--]=-1;
			else a[left++]=-1;
		}
		
	}
	
	return 0;
	
}
```

Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d"
.LC1:
	.string	"%d %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
	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
	leaq	.LC0(%rip), %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	movq	%rbp, %rdi
	subq	$56, %rsp
	.cfi_def_cfa_offset 112
	movq	%fs:40, %rax
	movq	%rax, 40(%rsp)
	xorl	%eax, %eax
	leaq	24(%rsp), %rsi
	call	__isoc99_scanf@PLT
	movslq	24(%rsp), %rdi
	movq	%rdi, %r12
	salq	$3, %rdi
	call	malloc@PLT
	movq	%rax, (%rsp)
	leaq	32(%rsp), %rax
	movq	%rax, 8(%rsp)
	testl	%r12d, %r12d
	jle	.L8
	leal	-1(%r12), %r14d
	xorl	%ebx, %ebx
	leaq	36(%rsp), %r13
	leaq	28(%rsp), %r15
	jmp	.L2
	.p2align 4,,10
	.p2align 3
.L3:
	cmpl	$1, %eax
	je	.L17
.L5:
	cmpl	$2, %eax
	je	.L18
.L6:
	addl	$1, %ebx
	cmpl	%ebx, 24(%rsp)
	jle	.L8
.L2:
	movq	%r13, %rsi
	movq	%rbp, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	36(%rsp), %eax
	testl	%eax, %eax
	jne	.L3
	movq	8(%rsp), %rdx
	movq	%r15, %rsi
	leaq	.LC1(%rip), %rdi
	call	__isoc99_scanf@PLT
	movl	28(%rsp), %edx
	testl	%edx, %edx
	je	.L4
	movl	32(%rsp), %edx
	movq	(%rsp), %rcx
	movslq	%r12d, %rax
	addl	$1, %r12d
	movl	%edx, (%rcx,%rax,4)
	movl	36(%rsp), %eax
	cmpl	$1, %eax
	jne	.L5
	.p2align 4,,10
	.p2align 3
.L17:
	movq	%r15, %rsi
	movq	%rbp, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	28(%rsp), %eax
	movq	(%rsp), %rcx
	leaq	.LC2(%rip), %rsi
	movl	$1, %edi
	addl	%r14d, %eax
	cltq
	movl	4(%rcx,%rax,4), %edx
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movl	36(%rsp), %eax
	cmpl	$2, %eax
	jne	.L6
.L18:
	movq	%r15, %rsi
	movq	%rbp, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	28(%rsp), %eax
	testl	%eax, %eax
	je	.L7
	movq	(%rsp), %rcx
	movslq	%r12d, %rax
	addl	$1, %ebx
	subl	$1, %r12d
	movl	$-1, (%rcx,%rax,4)
	cmpl	%ebx, 24(%rsp)
	jg	.L2
	.p2align 4,,10
	.p2align 3
.L8:
	movq	40(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L19
	addq	$56, %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
	.p2align 4,,10
	.p2align 3
.L4:
	.cfi_restore_state
	movl	32(%rsp), %edx
	movq	(%rsp), %rcx
	movslq	%r14d, %rax
	subl	$1, %r14d
	movl	%edx, (%rcx,%rax,4)
	movl	36(%rsp), %eax
	jmp	.L3
	.p2align 4,,10
	.p2align 3
.L7:
	movq	(%rsp), %rcx
	movslq	%r14d, %rax
	addl	$1, %r14d
	movl	$-1, (%rcx,%rax,4)
	jmp	.L6
.L19:
	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:
```

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.
Optimized Assembly Code:

train
```assembly
	.file	"temp.c"
	.text
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d"
.LC1:
	.string	"%d %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
	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
	leaq	.LC0(%rip), %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	movq	%rbp, %rdi
	subq	$56, %rsp
	.cfi_def_cfa_offset 112
	movq	%fs:40, %rax
	movq	%rax, 40(%rsp)
	xorl	%eax, %eax
	leaq	24(%rsp), %rsi
	call	__isoc99_scanf@PLT
	movslq	24(%rsp), %rdi
	movq	%rdi, %r12
	salq	$3, %rdi
	call	malloc@PLT
	movq	%rax, (%rsp)
	leaq	32(%rsp), %rax
	movq	%rax, 8(%rsp)
	testl	%r12d, %r12d
	jle	.L8
	leal	-1(%r12), %r14d
	xorl	%ebx, %ebx
	leaq	36(%rsp), %r13
	leaq	28(%rsp), %r15
	jmp	.L2
	.p2align 4,,10
	.p2align 3
.L3:
	cmpl	$1, %eax
	je	.L17
.L5:
	cmpl	$2, %eax
	je	.L18
.L6:
	addl	$1, %ebx
	cmpl	%ebx, 24(%rsp)
	jle	.L8
.L2:
	movq	%r13, %rsi
	movq	%rbp, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	36(%rsp), %eax
	testl	%eax, %eax
	jne	.L3
	movq	8(%rsp), %rdx
	movq	%r15, %rsi
	leaq	.LC1(%rip), %rdi
	call	__isoc99_scanf@PLT
	movl	28(%rsp), %edx
	testl	%edx, %edx
	je	.L4
	movl	32(%rsp), %edx
	movq	(%rsp), %rcx
	movslq	%r12d, %rax
	addl	$1, %r12d
	movl	%edx, (%rcx,%rax,4)
	movl	36(%rsp), %eax
	cmpl	$1, %eax
	jne	.L5
	.p2align 4,,10
	.p2align 3
.L17:
	movq	%r15, %rsi
	movq	%rbp, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	28(%rsp), %eax
	movq	(%rsp), %rcx
	leaq	.LC2(%rip), %rsi
	movl	$1, %edi
	addl	%r14d, %eax
	cltq
	movl	4(%rcx,%rax,4), %edx
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movl	36(%rsp), %eax
	cmpl	$2, %eax
	jne	.L6
.L18:
	movq	%r15, %rsi
	movq	%rbp, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	28(%rsp), %eax
	testl	%eax, %eax
	je	.L7
	movq	(%rsp), %rcx
	movslq	%r12d, %rax
	addl	$1, %ebx
	subl	$1, %r12d
	movl	$-1, (%rcx,%rax,4)
	cmpl	%ebx, 24(%rsp)
	jg	.L2
	.p2align 4,,10
	.p2align 3
.L8:
	movq	40(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L19
	addq	$56, %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
	.p2align 4,,10
	.p2align 3
.L4:
	.cfi_restore_state
	movl	32(%rsp), %edx
	movq	(%rsp), %rcx
	movslq	%r14d, %rax
	subl	$1, %r14d
	movl	%edx, (%rcx,%rax,4)
	movl	36(%rsp), %eax
	jmp	.L3
	.p2align 4,,10
	.p2align 3
.L7:
	movq	(%rsp), %rcx
	movslq	%r14d, %rax
	addl	$1, %r14d
	movl	$-1, (%rcx,%rax,4)
	jmp	.L6
.L19:
	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:
```