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 i,  n, q, nq, t, x;
  fscanf(stdin, "%d %d", &n, &nq);
  int **stack = (int**)malloc(sizeof(int*)*n);
  int *sp = (int*)malloc(sizeof(int)*n);
  for (i=0; i<n; i++) {
    stack[i] = (int*)malloc(sizeof(int)*nq);
    sp[i]=-1;
  }
  
  for (i=0; i<nq; i++) {
    fscanf(stdin, "%d %d", &q, &t);
    switch (q) {
    case 0:
      fscanf(stdin, "%d", &x);
      stack[t][++sp[t]] = x;
      break;
    case 1:
      if (sp[t]>=0)
	printf("%d\n", stack[t][sp[t]]);
      break;
    case 2:
      if (sp[t]>=0) sp[t]--;
    }
  }
  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
	leaq	.LC0(%rip), %r12
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	movq	%r12, %rsi
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$56, %rsp
	.cfi_def_cfa_offset 112
	movq	stdin(%rip), %rdi
	movq	%fs:40, %rax
	movq	%rax, 40(%rsp)
	xorl	%eax, %eax
	leaq	28(%rsp), %rcx
	leaq	20(%rsp), %rdx
	call	__isoc99_fscanf@PLT
	movslq	20(%rsp), %r13
	leaq	0(,%r13,8), %rdi
	call	malloc@PLT
	leaq	0(,%r13,4), %rdi
	movq	%rax, %rbp
	call	malloc@PLT
	movq	%rax, %rbx
	testl	%r13d, %r13d
	jle	.L2
	movslq	28(%rsp), %r14
	xorl	%r15d, %r15d
	movl	%r14d, 12(%rsp)
	salq	$2, %r14
	.p2align 4,,10
	.p2align 3
.L3:
	movq	%r14, %rdi
	call	malloc@PLT
	movl	$-1, (%rbx,%r15,4)
	movq	%rax, 0(%rbp,%r15,8)
	addq	$1, %r15
	cmpq	%r15, %r13
	jne	.L3
.L4:
	leaq	36(%rsp), %rax
	xorl	%r15d, %r15d
	leaq	32(%rsp), %r14
	movq	%rax, (%rsp)
	movl	12(%rsp), %eax
	leaq	24(%rsp), %r13
	testl	%eax, %eax
	jg	.L5
	jmp	.L9
	.p2align 4,,10
	.p2align 3
.L19:
	testl	%eax, %eax
	je	.L18
.L8:
	addl	$1, %r15d
	cmpl	%r15d, 28(%rsp)
	jle	.L9
.L5:
	movq	stdin(%rip), %rdi
	movq	%r14, %rcx
	movq	%r13, %rdx
	movq	%r12, %rsi
	xorl	%eax, %eax
	call	__isoc99_fscanf@PLT
	movl	24(%rsp), %eax
	cmpl	$1, %eax
	je	.L6
	cmpl	$2, %eax
	jne	.L19
	movslq	32(%rsp), %rax
	leaq	(%rbx,%rax,4), %rdx
	movl	(%rdx), %eax
	testl	%eax, %eax
	js	.L8
	subl	$1, %eax
	addl	$1, %r15d
	movl	%eax, (%rdx)
	cmpl	%r15d, 28(%rsp)
	jg	.L5
	.p2align 4,,10
	.p2align 3
.L9:
	movq	40(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L20
	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
.L6:
	.cfi_restore_state
	movslq	32(%rsp), %rdx
	movslq	(%rbx,%rdx,4), %rax
	testl	%eax, %eax
	js	.L8
	movq	0(%rbp,%rdx,8), %rdx
	leaq	.LC2(%rip), %rsi
	movl	$1, %edi
	movl	(%rdx,%rax,4), %edx
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L8
	.p2align 4,,10
	.p2align 3
.L18:
	movq	(%rsp), %rdx
	movq	stdin(%rip), %rdi
	leaq	.LC1(%rip), %rsi
	call	__isoc99_fscanf@PLT
	movslq	32(%rsp), %rax
	leaq	(%rbx,%rax,4), %rdx
	movq	0(%rbp,%rax,8), %rcx
	movl	(%rdx), %eax
	addl	$1, %eax
	movl	%eax, (%rdx)
	movl	36(%rsp), %edx
	cltq
	movl	%edx, (%rcx,%rax,4)
	jmp	.L8
.L2:
	movl	28(%rsp), %eax
	movl	%eax, 12(%rsp)
	jmp	.L4
.L20:
	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
	leaq	.LC0(%rip), %r12
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	movq	%r12, %rsi
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$56, %rsp
	.cfi_def_cfa_offset 112
	movq	stdin(%rip), %rdi
	movq	%fs:40, %rax
	movq	%rax, 40(%rsp)
	xorl	%eax, %eax
	leaq	28(%rsp), %rcx
	leaq	20(%rsp), %rdx
	call	__isoc99_fscanf@PLT
	movslq	20(%rsp), %r13
	leaq	0(,%r13,8), %rdi
	call	malloc@PLT
	leaq	0(,%r13,4), %rdi
	movq	%rax, %rbp
	call	malloc@PLT
	movq	%rax, %rbx
	testl	%r13d, %r13d
	jle	.L2
	movslq	28(%rsp), %r14
	xorl	%r15d, %r15d
	movl	%r14d, 12(%rsp)
	salq	$2, %r14
	.p2align 4,,10
	.p2align 3
.L3:
	movq	%r14, %rdi
	call	malloc@PLT
	movl	$-1, (%rbx,%r15,4)
	movq	%rax, 0(%rbp,%r15,8)
	addq	$1, %r15
	cmpq	%r15, %r13
	jne	.L3
.L4:
	leaq	36(%rsp), %rax
	xorl	%r15d, %r15d
	leaq	32(%rsp), %r14
	movq	%rax, (%rsp)
	movl	12(%rsp), %eax
	leaq	24(%rsp), %r13
	testl	%eax, %eax
	jg	.L5
	jmp	.L9
	.p2align 4,,10
	.p2align 3
.L19:
	testl	%eax, %eax
	je	.L18
.L8:
	addl	$1, %r15d
	cmpl	%r15d, 28(%rsp)
	jle	.L9
.L5:
	movq	stdin(%rip), %rdi
	movq	%r14, %rcx
	movq	%r13, %rdx
	movq	%r12, %rsi
	xorl	%eax, %eax
	call	__isoc99_fscanf@PLT
	movl	24(%rsp), %eax
	cmpl	$1, %eax
	je	.L6
	cmpl	$2, %eax
	jne	.L19
	movslq	32(%rsp), %rax
	leaq	(%rbx,%rax,4), %rdx
	movl	(%rdx), %eax
	testl	%eax, %eax
	js	.L8
	subl	$1, %eax
	addl	$1, %r15d
	movl	%eax, (%rdx)
	cmpl	%r15d, 28(%rsp)
	jg	.L5
	.p2align 4,,10
	.p2align 3
.L9:
	movq	40(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L20
	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
.L6:
	.cfi_restore_state
	movslq	32(%rsp), %rdx
	movslq	(%rbx,%rdx,4), %rax
	testl	%eax, %eax
	js	.L8
	movq	0(%rbp,%rdx,8), %rdx
	leaq	.LC2(%rip), %rsi
	movl	$1, %edi
	movl	(%rdx,%rax,4), %edx
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L8
	.p2align 4,,10
	.p2align 3
.L18:
	movq	(%rsp), %rdx
	movq	stdin(%rip), %rdi
	leaq	.LC1(%rip), %rsi
	call	__isoc99_fscanf@PLT
	movslq	32(%rsp), %rax
	leaq	(%rbx,%rax,4), %rdx
	movq	0(%rbp,%rax,8), %rcx
	movl	(%rdx), %eax
	addl	$1, %eax
	movl	%eax, (%rdx)
	movl	36(%rsp), %edx
	cltq
	movl	%edx, (%rcx,%rax,4)
	jmp	.L8
.L2:
	movl	28(%rsp), %eax
	movl	%eax, 12(%rsp)
	jmp	.L4
.L20:
	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
	leaq	.LC0(%rip), %r12
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	movq	%r12, %rsi
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$56, %rsp
	.cfi_def_cfa_offset 112
	movq	stdin(%rip), %rdi
	movq	%fs:40, %rax
	movq	%rax, 40(%rsp)
	xorl	%eax, %eax
	leaq	28(%rsp), %rcx
	leaq	20(%rsp), %rdx
	call	__isoc99_fscanf@PLT
	movslq	20(%rsp), %r13
	leaq	0(,%r13,8), %rdi
	call	malloc@PLT
	leaq	0(,%r13,4), %rdi
	movq	%rax, %rbp
	call	malloc@PLT
	movq	%rax, %rbx
	testl	%r13d, %r13d
	jle	.L2
	movslq	28(%rsp), %r14
	xorl	%r15d, %r15d
	movl	%r14d, 12(%rsp)
	salq	$2, %r14
	.p2align 4,,10
	.p2align 3
.L3:
	movq	%r14, %rdi
	call	malloc@PLT
	movl	$-1, (%rbx,%r15,4)
	movq	%rax, 0(%rbp,%r15,8)
	addq	$1, %r15
	cmpq	%r15, %r13
	jne	.L3
.L4:
	leaq	36(%rsp), %rax
	xorl	%r15d, %r15d
	leaq	32(%rsp), %r14
	movq	%rax, (%rsp)
	movl	12(%rsp), %eax
	leaq	24(%rsp), %r13
	testl	%eax, %eax
	jg	.L5
	jmp	.L9
	.p2align 4,,10
	.p2align 3
.L19:
	testl	%eax, %eax
	je	.L18
.L8:
	addl	$1, %r15d
	cmpl	%r15d, 28(%rsp)
	jle	.L9
.L5:
	movq	stdin(%rip), %rdi
	movq	%r14, %rcx
	movq	%r13, %rdx
	movq	%r12, %rsi
	xorl	%eax, %eax
	call	__isoc99_fscanf@PLT
	movl	24(%rsp), %eax
	cmpl	$1, %eax
	je	.L6
	cmpl	$2, %eax
	jne	.L19
	movslq	32(%rsp), %rax
	leaq	(%rbx,%rax,4), %rdx
	movl	(%rdx), %eax
	testl	%eax, %eax
	js	.L8
	subl	$1, %eax
	addl	$1, %r15d
	movl	%eax, (%rdx)
	cmpl	%r15d, 28(%rsp)
	jg	.L5
	.p2align 4,,10
	.p2align 3
.L9:
	movq	40(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L20
	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
.L6:
	.cfi_restore_state
	movslq	32(%rsp), %rdx
	movslq	(%rbx,%rdx,4), %rax
	testl	%eax, %eax
	js	.L8
	movq	0(%rbp,%rdx,8), %rdx
	leaq	.LC2(%rip), %rsi
	movl	$1, %edi
	movl	(%rdx,%rax,4), %edx
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L8
	.p2align 4,,10
	.p2align 3
.L18:
	movq	(%rsp), %rdx
	movq	stdin(%rip), %rdi
	leaq	.LC1(%rip), %rsi
	call	__isoc99_fscanf@PLT
	movslq	32(%rsp), %rax
	leaq	(%rbx,%rax,4), %rdx
	movq	0(%rbp,%rax,8), %rcx
	movl	(%rdx), %eax
	addl	$1, %eax
	movl	%eax, (%rdx)
	movl	36(%rsp), %edx
	cltq
	movl	%edx, (%rcx,%rax,4)
	jmp	.L8
.L2:
	movl	28(%rsp), %eax
	movl	%eax, 12(%rsp)
	jmp	.L4
.L20:
	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 i,  n, q, nq, t, x;
  fscanf(stdin, "%d %d", &n, &nq);
  int **stack = (int**)malloc(sizeof(int*)*n);
  int *sp = (int*)malloc(sizeof(int)*n);
  for (i=0; i<n; i++) {
    stack[i] = (int*)malloc(sizeof(int)*nq);
    sp[i]=-1;
  }
  
  for (i=0; i<nq; i++) {
    fscanf(stdin, "%d %d", &q, &t);
    switch (q) {
    case 0:
      fscanf(stdin, "%d", &x);
      stack[t][++sp[t]] = x;
      break;
    case 1:
      if (sp[t]>=0)
	printf("%d\n", stack[t][sp[t]]);
      break;
    case 2:
      if (sp[t]>=0) sp[t]--;
    }
  }
  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 i,  n, q, nq, t, x;
  fscanf(stdin, "%d %d", &n, &nq);
  int **stack = (int**)malloc(sizeof(int*)*n);
  int *sp = (int*)malloc(sizeof(int)*n);
  for (i=0; i<n; i++) {
    stack[i] = (int*)malloc(sizeof(int)*nq);
    sp[i]=-1;
  }
  
  for (i=0; i<nq; i++) {
    fscanf(stdin, "%d %d", &q, &t);
    switch (q) {
    case 0:
      fscanf(stdin, "%d", &x);
      stack[t][++sp[t]] = x;
      break;
    case 1:
      if (sp[t]>=0)
	printf("%d\n", stack[t][sp[t]]);
      break;
    case 2:
      if (sp[t]>=0) sp[t]--;
    }
  }
  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>

int main()
{
  int i,  n, q, nq, t, x;
  fscanf(stdin, "%d %d", &n, &nq);
  int **stack = (int**)malloc(sizeof(int*)*n);
  int *sp = (int*)malloc(sizeof(int)*n);
  for (i=0; i<n; i++) {
    stack[i] = (int*)malloc(sizeof(int)*nq);
    sp[i]=-1;
  }
  
  for (i=0; i<nq; i++) {
    fscanf(stdin, "%d %d", &q, &t);
    switch (q) {
    case 0:
      fscanf(stdin, "%d", &x);
      stack[t][++sp[t]] = x;
      break;
    case 1:
      if (sp[t]>=0)
	printf("%d\n", stack[t][sp[t]]);
      break;
    case 2:
      if (sp[t]>=0) sp[t]--;
    }
  }
  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
	leaq	.LC0(%rip), %r12
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	movq	%r12, %rsi
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$56, %rsp
	.cfi_def_cfa_offset 112
	movq	stdin(%rip), %rdi
	movq	%fs:40, %rax
	movq	%rax, 40(%rsp)
	xorl	%eax, %eax
	leaq	28(%rsp), %rcx
	leaq	20(%rsp), %rdx
	call	__isoc99_fscanf@PLT
	movslq	20(%rsp), %r13
	leaq	0(,%r13,8), %rdi
	call	malloc@PLT
	leaq	0(,%r13,4), %rdi
	movq	%rax, %rbp
	call	malloc@PLT
	movq	%rax, %rbx
	testl	%r13d, %r13d
	jle	.L2
	movslq	28(%rsp), %r14
	xorl	%r15d, %r15d
	movl	%r14d, 12(%rsp)
	salq	$2, %r14
	.p2align 4,,10
	.p2align 3
.L3:
	movq	%r14, %rdi
	call	malloc@PLT
	movl	$-1, (%rbx,%r15,4)
	movq	%rax, 0(%rbp,%r15,8)
	addq	$1, %r15
	cmpq	%r15, %r13
	jne	.L3
.L4:
	leaq	36(%rsp), %rax
	xorl	%r15d, %r15d
	leaq	32(%rsp), %r14
	movq	%rax, (%rsp)
	movl	12(%rsp), %eax
	leaq	24(%rsp), %r13
	testl	%eax, %eax
	jg	.L5
	jmp	.L9
	.p2align 4,,10
	.p2align 3
.L19:
	testl	%eax, %eax
	je	.L18
.L8:
	addl	$1, %r15d
	cmpl	%r15d, 28(%rsp)
	jle	.L9
.L5:
	movq	stdin(%rip), %rdi
	movq	%r14, %rcx
	movq	%r13, %rdx
	movq	%r12, %rsi
	xorl	%eax, %eax
	call	__isoc99_fscanf@PLT
	movl	24(%rsp), %eax
	cmpl	$1, %eax
	je	.L6
	cmpl	$2, %eax
	jne	.L19
	movslq	32(%rsp), %rax
	leaq	(%rbx,%rax,4), %rdx
	movl	(%rdx), %eax
	testl	%eax, %eax
	js	.L8
	subl	$1, %eax
	addl	$1, %r15d
	movl	%eax, (%rdx)
	cmpl	%r15d, 28(%rsp)
	jg	.L5
	.p2align 4,,10
	.p2align 3
.L9:
	movq	40(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L20
	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
.L6:
	.cfi_restore_state
	movslq	32(%rsp), %rdx
	movslq	(%rbx,%rdx,4), %rax
	testl	%eax, %eax
	js	.L8
	movq	0(%rbp,%rdx,8), %rdx
	leaq	.LC2(%rip), %rsi
	movl	$1, %edi
	movl	(%rdx,%rax,4), %edx
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L8
	.p2align 4,,10
	.p2align 3
.L18:
	movq	(%rsp), %rdx
	movq	stdin(%rip), %rdi
	leaq	.LC1(%rip), %rsi
	call	__isoc99_fscanf@PLT
	movslq	32(%rsp), %rax
	leaq	(%rbx,%rax,4), %rdx
	movq	0(%rbp,%rax,8), %rcx
	movl	(%rdx), %eax
	addl	$1, %eax
	movl	%eax, (%rdx)
	movl	36(%rsp), %edx
	cltq
	movl	%edx, (%rcx,%rax,4)
	jmp	.L8
.L2:
	movl	28(%rsp), %eax
	movl	%eax, 12(%rsp)
	jmp	.L4
.L20:
	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
	leaq	.LC0(%rip), %r12
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	movq	%r12, %rsi
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$56, %rsp
	.cfi_def_cfa_offset 112
	movq	stdin(%rip), %rdi
	movq	%fs:40, %rax
	movq	%rax, 40(%rsp)
	xorl	%eax, %eax
	leaq	28(%rsp), %rcx
	leaq	20(%rsp), %rdx
	call	__isoc99_fscanf@PLT
	movslq	20(%rsp), %r13
	leaq	0(,%r13,8), %rdi
	call	malloc@PLT
	leaq	0(,%r13,4), %rdi
	movq	%rax, %rbp
	call	malloc@PLT
	movq	%rax, %rbx
	testl	%r13d, %r13d
	jle	.L2
	movslq	28(%rsp), %r14
	xorl	%r15d, %r15d
	movl	%r14d, 12(%rsp)
	salq	$2, %r14
	.p2align 4,,10
	.p2align 3
.L3:
	movq	%r14, %rdi
	call	malloc@PLT
	movl	$-1, (%rbx,%r15,4)
	movq	%rax, 0(%rbp,%r15,8)
	addq	$1, %r15
	cmpq	%r15, %r13
	jne	.L3
.L4:
	leaq	36(%rsp), %rax
	xorl	%r15d, %r15d
	leaq	32(%rsp), %r14
	movq	%rax, (%rsp)
	movl	12(%rsp), %eax
	leaq	24(%rsp), %r13
	testl	%eax, %eax
	jg	.L5
	jmp	.L9
	.p2align 4,,10
	.p2align 3
.L19:
	testl	%eax, %eax
	je	.L18
.L8:
	addl	$1, %r15d
	cmpl	%r15d, 28(%rsp)
	jle	.L9
.L5:
	movq	stdin(%rip), %rdi
	movq	%r14, %rcx
	movq	%r13, %rdx
	movq	%r12, %rsi
	xorl	%eax, %eax
	call	__isoc99_fscanf@PLT
	movl	24(%rsp), %eax
	cmpl	$1, %eax
	je	.L6
	cmpl	$2, %eax
	jne	.L19
	movslq	32(%rsp), %rax
	leaq	(%rbx,%rax,4), %rdx
	movl	(%rdx), %eax
	testl	%eax, %eax
	js	.L8
	subl	$1, %eax
	addl	$1, %r15d
	movl	%eax, (%rdx)
	cmpl	%r15d, 28(%rsp)
	jg	.L5
	.p2align 4,,10
	.p2align 3
.L9:
	movq	40(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L20
	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
.L6:
	.cfi_restore_state
	movslq	32(%rsp), %rdx
	movslq	(%rbx,%rdx,4), %rax
	testl	%eax, %eax
	js	.L8
	movq	0(%rbp,%rdx,8), %rdx
	leaq	.LC2(%rip), %rsi
	movl	$1, %edi
	movl	(%rdx,%rax,4), %edx
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L8
	.p2align 4,,10
	.p2align 3
.L18:
	movq	(%rsp), %rdx
	movq	stdin(%rip), %rdi
	leaq	.LC1(%rip), %rsi
	call	__isoc99_fscanf@PLT
	movslq	32(%rsp), %rax
	leaq	(%rbx,%rax,4), %rdx
	movq	0(%rbp,%rax,8), %rcx
	movl	(%rdx), %eax
	addl	$1, %eax
	movl	%eax, (%rdx)
	movl	36(%rsp), %edx
	cltq
	movl	%edx, (%rcx,%rax,4)
	jmp	.L8
.L2:
	movl	28(%rsp), %eax
	movl	%eax, 12(%rsp)
	jmp	.L4
.L20:
	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:
```