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>
#define N 1000

typedef struct stack{
	int *a;
	int top;
}stack;

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

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%d %d"
.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	$4096, %rsp
	orq	$0, (%rsp)
	subq	$4096, %rsp
	orq	$0, (%rsp)
	subq	$4096, %rsp
	orq	$0, (%rsp)
	subq	$3760, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-16036(%rbp), %rdx
	leaq	-16040(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -16020(%rbp)
	jmp	.L2
.L3:
	movl	-16020(%rbp), %eax
	cltq
	salq	$4, %rax
	addq	%rbp, %rax
	subq	$16008, %rax
	movl	$0, (%rax)
	movl	-16036(%rbp), %eax
	cltq
	salq	$2, %rax
	movq	%rax, %rdi
	call	malloc@PLT
	movq	%rax, %rdx
	movl	-16020(%rbp), %eax
	cltq
	salq	$4, %rax
	addq	%rbp, %rax
	subq	$16016, %rax
	movq	%rdx, (%rax)
	addl	$1, -16020(%rbp)
.L2:
	movl	-16040(%rbp), %eax
	cmpl	%eax, -16020(%rbp)
	jl	.L3
	movl	$0, -16020(%rbp)
	jmp	.L4
.L8:
	leaq	-16024(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-16024(%rbp), %eax
	testl	%eax, %eax
	jne	.L5
	leaq	-16028(%rbp), %rdx
	leaq	-16032(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-16032(%rbp), %eax
	cltq
	salq	$4, %rax
	addq	%rbp, %rax
	subq	$16016, %rax
	movq	(%rax), %rsi
	movl	-16032(%rbp), %edx
	movslq	%edx, %rax
	salq	$4, %rax
	addq	%rbp, %rax
	subq	$16008, %rax
	movl	(%rax), %eax
	leal	1(%rax), %ecx
	movslq	%edx, %rdx
	salq	$4, %rdx
	addq	%rbp, %rdx
	subq	$16008, %rdx
	movl	%ecx, (%rdx)
	cltq
	salq	$2, %rax
	leaq	(%rsi,%rax), %rdx
	movl	-16028(%rbp), %eax
	movl	%eax, (%rdx)
	jmp	.L6
.L5:
	movl	-16024(%rbp), %eax
	cmpl	$1, %eax
	jne	.L7
	leaq	-16032(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-16032(%rbp), %eax
	cltq
	salq	$4, %rax
	addq	%rbp, %rax
	subq	$16008, %rax
	movl	(%rax), %eax
	testl	%eax, %eax
	je	.L6
	movl	-16032(%rbp), %eax
	cltq
	salq	$4, %rax
	addq	%rbp, %rax
	subq	$16016, %rax
	movq	(%rax), %rdx
	movl	-16032(%rbp), %eax
	cltq
	salq	$4, %rax
	addq	%rbp, %rax
	subq	$16008, %rax
	movl	(%rax), %eax
	cltq
	salq	$2, %rax
	subq	$4, %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L6
.L7:
	movl	-16024(%rbp), %eax
	cmpl	$2, %eax
	jne	.L6
	leaq	-16032(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-16032(%rbp), %eax
	cltq
	salq	$4, %rax
	addq	%rbp, %rax
	subq	$16008, %rax
	movl	(%rax), %eax
	testl	%eax, %eax
	je	.L6
	movl	-16032(%rbp), %eax
	movslq	%eax, %rdx
	salq	$4, %rdx
	addq	%rbp, %rdx
	subq	$16008, %rdx
	movl	(%rdx), %edx
	subl	$1, %edx
	cltq
	salq	$4, %rax
	addq	%rbp, %rax
	subq	$16008, %rax
	movl	%edx, (%rax)
.L6:
	addl	$1, -16020(%rbp)
.L4:
	movl	-16036(%rbp), %eax
	cmpl	%eax, -16020(%rbp)
	jl	.L8
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L10
	call	__stack_chk_fail@PLT
.L10:
	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 %d"
.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
	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	$4096, %rsp
	.cfi_def_cfa_offset 4152
	orq	$0, (%rsp)
	subq	$4096, %rsp
	.cfi_def_cfa_offset 8248
	orq	$0, (%rsp)
	subq	$4096, %rsp
	.cfi_def_cfa_offset 12344
	orq	$0, (%rsp)
	subq	$3768, %rsp
	.cfi_def_cfa_offset 16112
	leaq	.LC0(%rip), %r13
	movq	%r13, %rdi
	movq	%fs:40, %rax
	movq	%rax, 16040(%rsp)
	xorl	%eax, %eax
	leaq	16(%rsp), %rdx
	leaq	12(%rsp), %rsi
	call	__isoc99_scanf@PLT
	movl	12(%rsp), %eax
	testl	%eax, %eax
	jle	.L2
	movslq	16(%rsp), %rbp
	subl	$1, %eax
	leaq	32(%rsp), %rbx
	salq	$4, %rax
	movq	%rbp, %r14
	leaq	48(%rsp,%rax), %r12
	salq	$2, %rbp
	.p2align 4,,10
	.p2align 3
.L3:
	movl	$0, 8(%rbx)
	movq	%rbp, %rdi
	addq	$16, %rbx
	call	malloc@PLT
	movq	%rax, -16(%rbx)
	cmpq	%r12, %rbx
	jne	.L3
.L4:
	xorl	%ebx, %ebx
	leaq	28(%rsp), %r12
	leaq	.LC1(%rip), %rbp
	leaq	.LC2(%rip), %r15
	testl	%r14d, %r14d
	jg	.L5
	jmp	.L11
	.p2align 4,,10
	.p2align 3
.L6:
	cmpl	$1, %eax
	je	.L23
	cmpl	$2, %eax
	je	.L24
.L7:
	addl	$1, %ebx
	cmpl	%ebx, 16(%rsp)
	jle	.L11
.L5:
	movq	%r12, %rsi
	movq	%rbp, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	28(%rsp), %eax
	testl	%eax, %eax
	jne	.L6
	leaq	24(%rsp), %rdx
	leaq	20(%rsp), %rsi
	movq	%r13, %rdi
	addl	$1, %ebx
	call	__isoc99_scanf@PLT
	movslq	20(%rsp), %rax
	salq	$4, %rax
	movslq	40(%rsp,%rax), %rdx
	movq	32(%rsp,%rax), %rcx
	leal	1(%rdx), %esi
	movl	%esi, 40(%rsp,%rax)
	movl	24(%rsp), %eax
	movl	%eax, (%rcx,%rdx,4)
	cmpl	%ebx, 16(%rsp)
	jg	.L5
.L11:
	movq	16040(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L25
	addq	$16056, %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
.L23:
	.cfi_restore_state
	leaq	20(%rsp), %rsi
	movq	%rbp, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movslq	20(%rsp), %rax
	salq	$4, %rax
	movslq	40(%rsp,%rax), %rdx
	testl	%edx, %edx
	je	.L7
	movq	32(%rsp,%rax), %rax
	movq	%r15, %rsi
	movl	$1, %edi
	movl	-4(%rax,%rdx,4), %edx
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L7
	.p2align 4,,10
	.p2align 3
.L24:
	leaq	20(%rsp), %rsi
	movq	%rbp, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movslq	20(%rsp), %rax
	salq	$4, %rax
	movl	40(%rsp,%rax), %edx
	testl	%edx, %edx
	je	.L7
	subl	$1, %edx
	movl	%edx, 40(%rsp,%rax)
	jmp	.L7
.L2:
	movl	16(%rsp), %r14d
	jmp	.L4
.L25:
	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 %d"
.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
	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	$4096, %rsp
	.cfi_def_cfa_offset 4152
	orq	$0, (%rsp)
	subq	$4096, %rsp
	.cfi_def_cfa_offset 8248
	orq	$0, (%rsp)
	subq	$4096, %rsp
	.cfi_def_cfa_offset 12344
	orq	$0, (%rsp)
	subq	$3768, %rsp
	.cfi_def_cfa_offset 16112
	leaq	.LC0(%rip), %r13
	movq	%r13, %rdi
	movq	%fs:40, %rax
	movq	%rax, 16040(%rsp)
	xorl	%eax, %eax
	leaq	16(%rsp), %rdx
	leaq	12(%rsp), %rsi
	call	__isoc99_scanf@PLT
	movl	12(%rsp), %eax
	testl	%eax, %eax
	jle	.L2
	movslq	16(%rsp), %rbp
	subl	$1, %eax
	leaq	32(%rsp), %rbx
	salq	$4, %rax
	movq	%rbp, %r14
	leaq	48(%rsp,%rax), %r12
	salq	$2, %rbp
	.p2align 4,,10
	.p2align 3
.L3:
	movl	$0, 8(%rbx)
	movq	%rbp, %rdi
	addq	$16, %rbx
	call	malloc@PLT
	movq	%rax, -16(%rbx)
	cmpq	%r12, %rbx
	jne	.L3
.L4:
	xorl	%ebx, %ebx
	leaq	28(%rsp), %r12
	leaq	.LC1(%rip), %rbp
	leaq	.LC2(%rip), %r15
	testl	%r14d, %r14d
	jg	.L5
	jmp	.L11
	.p2align 4,,10
	.p2align 3
.L6:
	cmpl	$1, %eax
	je	.L23
	cmpl	$2, %eax
	je	.L24
.L7:
	addl	$1, %ebx
	cmpl	%ebx, 16(%rsp)
	jle	.L11
.L5:
	movq	%r12, %rsi
	movq	%rbp, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	28(%rsp), %eax
	testl	%eax, %eax
	jne	.L6
	leaq	24(%rsp), %rdx
	leaq	20(%rsp), %rsi
	movq	%r13, %rdi
	addl	$1, %ebx
	call	__isoc99_scanf@PLT
	movslq	20(%rsp), %rax
	salq	$4, %rax
	movslq	40(%rsp,%rax), %rdx
	movq	32(%rsp,%rax), %rcx
	leal	1(%rdx), %esi
	movl	%esi, 40(%rsp,%rax)
	movl	24(%rsp), %eax
	movl	%eax, (%rcx,%rdx,4)
	cmpl	%ebx, 16(%rsp)
	jg	.L5
.L11:
	movq	16040(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L25
	addq	$16056, %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
.L23:
	.cfi_restore_state
	leaq	20(%rsp), %rsi
	movq	%rbp, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movslq	20(%rsp), %rax
	salq	$4, %rax
	movslq	40(%rsp,%rax), %rdx
	testl	%edx, %edx
	je	.L7
	movq	32(%rsp,%rax), %rax
	movq	%r15, %rsi
	movl	$1, %edi
	movl	-4(%rax,%rdx,4), %edx
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L7
	.p2align 4,,10
	.p2align 3
.L24:
	leaq	20(%rsp), %rsi
	movq	%rbp, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movslq	20(%rsp), %rax
	salq	$4, %rax
	movl	40(%rsp,%rax), %edx
	testl	%edx, %edx
	je	.L7
	subl	$1, %edx
	movl	%edx, 40(%rsp,%rax)
	jmp	.L7
.L2:
	movl	16(%rsp), %r14d
	jmp	.L4
.L25:
	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>
#define N 1000

typedef struct stack{
	int *a;
	int top;
}stack;

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

3 9
0 0 0
0 0 2
0 0 3
0 2 4
0 2 5
1 0
1 2
2 0
1 0
 3 9
0 0 0
0 0 2
0 0 3
0 2 4
0 0 5
1 0
1 2
2 0
1 0
 3 9
0 0 0
0 0 2
0 0 3
0 2 4
0 2 5
1 1
1 2
2 0
1 0
 6 9
0 0 0
0 0 2
0 0 3
0 2 4
0 0 5
1 1
1 2
2 0
1 0
 3 9
0 0 0
0 0 2
0 0 1
0 2 4
0 2 9
1 1
1 2
2 0
1 0
 3 9
0 0 1
0 0 2
0 0 6
0 2 4
0 2 5
1 0
1 2
2 0
1 0
 6 9
0 0 0
0 0 2
0 0 1
0 2 4
0 0 5
1 0
1 2
2 0
1 0
 3 9
0 0 0
0 0 2
0 0 1
0 2 4
0 2 9
1 1
1 2
1 0
1 0
 3 12
0 0 1
0 0 2
0 0 6
0 2 4
0 2 5
1 0
1 2
2 0
1 0
 3 9
0 0 0
0 0 2
0 0 1
0 0 4
0 2 9
1 1
1 2
1 0
1 0

3
5
2
 5
4
3
 5
2
 4
3
 9
2
 6
5
2
 5
4
1
 9
1
1
 6
5
2
2
2
2
 9
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>
#define N 1000

typedef struct stack{
	int *a;
	int top;
}stack;

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

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%d %d"
.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	$4096, %rsp
	orq	$0, (%rsp)
	subq	$4096, %rsp
	orq	$0, (%rsp)
	subq	$4096, %rsp
	orq	$0, (%rsp)
	subq	$3760, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-16036(%rbp), %rdx
	leaq	-16040(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -16020(%rbp)
	jmp	.L2
.L3:
	movl	-16020(%rbp), %eax
	cltq
	salq	$4, %rax
	addq	%rbp, %rax
	subq	$16008, %rax
	movl	$0, (%rax)
	movl	-16036(%rbp), %eax
	cltq
	salq	$2, %rax
	movq	%rax, %rdi
	call	malloc@PLT
	movq	%rax, %rdx
	movl	-16020(%rbp), %eax
	cltq
	salq	$4, %rax
	addq	%rbp, %rax
	subq	$16016, %rax
	movq	%rdx, (%rax)
	addl	$1, -16020(%rbp)
.L2:
	movl	-16040(%rbp), %eax
	cmpl	%eax, -16020(%rbp)
	jl	.L3
	movl	$0, -16020(%rbp)
	jmp	.L4
.L8:
	leaq	-16024(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-16024(%rbp), %eax
	testl	%eax, %eax
	jne	.L5
	leaq	-16028(%rbp), %rdx
	leaq	-16032(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-16032(%rbp), %eax
	cltq
	salq	$4, %rax
	addq	%rbp, %rax
	subq	$16016, %rax
	movq	(%rax), %rsi
	movl	-16032(%rbp), %edx
	movslq	%edx, %rax
	salq	$4, %rax
	addq	%rbp, %rax
	subq	$16008, %rax
	movl	(%rax), %eax
	leal	1(%rax), %ecx
	movslq	%edx, %rdx
	salq	$4, %rdx
	addq	%rbp, %rdx
	subq	$16008, %rdx
	movl	%ecx, (%rdx)
	cltq
	salq	$2, %rax
	leaq	(%rsi,%rax), %rdx
	movl	-16028(%rbp), %eax
	movl	%eax, (%rdx)
	jmp	.L6
.L5:
	movl	-16024(%rbp), %eax
	cmpl	$1, %eax
	jne	.L7
	leaq	-16032(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-16032(%rbp), %eax
	cltq
	salq	$4, %rax
	addq	%rbp, %rax
	subq	$16008, %rax
	movl	(%rax), %eax
	testl	%eax, %eax
	je	.L6
	movl	-16032(%rbp), %eax
	cltq
	salq	$4, %rax
	addq	%rbp, %rax
	subq	$16016, %rax
	movq	(%rax), %rdx
	movl	-16032(%rbp), %eax
	cltq
	salq	$4, %rax
	addq	%rbp, %rax
	subq	$16008, %rax
	movl	(%rax), %eax
	cltq
	salq	$2, %rax
	subq	$4, %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L6
.L7:
	movl	-16024(%rbp), %eax
	cmpl	$2, %eax
	jne	.L6
	leaq	-16032(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-16032(%rbp), %eax
	cltq
	salq	$4, %rax
	addq	%rbp, %rax
	subq	$16008, %rax
	movl	(%rax), %eax
	testl	%eax, %eax
	je	.L6
	movl	-16032(%rbp), %eax
	movslq	%eax, %rdx
	salq	$4, %rdx
	addq	%rbp, %rdx
	subq	$16008, %rdx
	movl	(%rdx), %edx
	subl	$1, %edx
	cltq
	salq	$4, %rax
	addq	%rbp, %rax
	subq	$16008, %rax
	movl	%edx, (%rax)
.L6:
	addl	$1, -16020(%rbp)
.L4:
	movl	-16036(%rbp), %eax
	cmpl	%eax, -16020(%rbp)
	jl	.L8
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L10
	call	__stack_chk_fail@PLT
.L10:
	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 %d"
.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	$4096, %rsp
	orq	$0, (%rsp)
	subq	$4096, %rsp
	orq	$0, (%rsp)
	subq	$4096, %rsp
	orq	$0, (%rsp)
	subq	$3760, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-16036(%rbp), %rdx
	leaq	-16040(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -16020(%rbp)
	jmp	.L2
.L3:
	movl	-16020(%rbp), %eax
	cltq
	salq	$4, %rax
	addq	%rbp, %rax
	subq	$16008, %rax
	movl	$0, (%rax)
	movl	-16036(%rbp), %eax
	cltq
	salq	$2, %rax
	movq	%rax, %rdi
	call	malloc@PLT
	movq	%rax, %rdx
	movl	-16020(%rbp), %eax
	cltq
	salq	$4, %rax
	addq	%rbp, %rax
	subq	$16016, %rax
	movq	%rdx, (%rax)
	addl	$1, -16020(%rbp)
.L2:
	movl	-16040(%rbp), %eax
	cmpl	%eax, -16020(%rbp)
	jl	.L3
	movl	$0, -16020(%rbp)
	jmp	.L4
.L8:
	leaq	-16024(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-16024(%rbp), %eax
	testl	%eax, %eax
	jne	.L5
	leaq	-16028(%rbp), %rdx
	leaq	-16032(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-16032(%rbp), %eax
	cltq
	salq	$4, %rax
	addq	%rbp, %rax
	subq	$16016, %rax
	movq	(%rax), %rsi
	movl	-16032(%rbp), %edx
	movslq	%edx, %rax
	salq	$4, %rax
	addq	%rbp, %rax
	subq	$16008, %rax
	movl	(%rax), %eax
	leal	1(%rax), %ecx
	movslq	%edx, %rdx
	salq	$4, %rdx
	addq	%rbp, %rdx
	subq	$16008, %rdx
	movl	%ecx, (%rdx)
	cltq
	salq	$2, %rax
	leaq	(%rsi,%rax), %rdx
	movl	-16028(%rbp), %eax
	movl	%eax, (%rdx)
	jmp	.L6
.L5:
	movl	-16024(%rbp), %eax
	cmpl	$1, %eax
	jne	.L7
	leaq	-16032(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-16032(%rbp), %eax
	cltq
	salq	$4, %rax
	addq	%rbp, %rax
	subq	$16008, %rax
	movl	(%rax), %eax
	testl	%eax, %eax
	je	.L6
	movl	-16032(%rbp), %eax
	cltq
	salq	$4, %rax
	addq	%rbp, %rax
	subq	$16016, %rax
	movq	(%rax), %rdx
	movl	-16032(%rbp), %eax
	cltq
	salq	$4, %rax
	addq	%rbp, %rax
	subq	$16008, %rax
	movl	(%rax), %eax
	cltq
	salq	$2, %rax
	subq	$4, %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L6
.L7:
	movl	-16024(%rbp), %eax
	cmpl	$2, %eax
	jne	.L6
	leaq	-16032(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-16032(%rbp), %eax
	cltq
	salq	$4, %rax
	addq	%rbp, %rax
	subq	$16008, %rax
	movl	(%rax), %eax
	testl	%eax, %eax
	je	.L6
	movl	-16032(%rbp), %eax
	movslq	%eax, %rdx
	salq	$4, %rdx
	addq	%rbp, %rdx
	subq	$16008, %rdx
	movl	(%rdx), %edx
	subl	$1, %edx
	cltq
	salq	$4, %rax
	addq	%rbp, %rax
	subq	$16008, %rax
	movl	%edx, (%rax)
.L6:
	addl	$1, -16020(%rbp)
.L4:
	movl	-16036(%rbp), %eax
	cmpl	%eax, -16020(%rbp)
	jl	.L8
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L10
	call	__stack_chk_fail@PLT
.L10:
	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:
