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>
#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;
	
}
```

Assembly Code:

```assembly
	.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:
```

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 %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
```assembly
	.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:
```
```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;
	
}
```
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>
#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;
	
}
```

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:

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 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;
	
}
```

Assembly Code:

```assembly
	.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:
```

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 %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:
```