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

```

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
	pushq	%rbx
	subq	$56, %rsp
	.cfi_offset 3, -24
	movq	%fs:40, %rax
	movq	%rax, -24(%rbp)
	xorl	%eax, %eax
	movq	stdin(%rip), %rax
	leaq	-56(%rbp), %rcx
	leaq	-64(%rbp), %rdx
	leaq	.LC0(%rip), %rsi
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_fscanf@PLT
	movl	-64(%rbp), %eax
	cltq
	salq	$3, %rax
	movq	%rax, %rdi
	call	malloc@PLT
	movq	%rax, -40(%rbp)
	movl	-64(%rbp), %eax
	cltq
	salq	$2, %rax
	movq	%rax, %rdi
	call	malloc@PLT
	movq	%rax, -32(%rbp)
	movl	$0, -44(%rbp)
	jmp	.L2
.L3:
	movl	-56(%rbp), %eax
	cltq
	salq	$2, %rax
	movl	-44(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,8), %rcx
	movq	-40(%rbp), %rdx
	leaq	(%rcx,%rdx), %rbx
	movq	%rax, %rdi
	call	malloc@PLT
	movq	%rax, (%rbx)
	movl	-44(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-32(%rbp), %rax
	addq	%rdx, %rax
	movl	$-1, (%rax)
	addl	$1, -44(%rbp)
.L2:
	movl	-64(%rbp), %eax
	cmpl	%eax, -44(%rbp)
	jl	.L3
	movl	$0, -44(%rbp)
	jmp	.L4
.L10:
	movq	stdin(%rip), %rax
	leaq	-52(%rbp), %rcx
	leaq	-60(%rbp), %rdx
	leaq	.LC0(%rip), %rsi
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_fscanf@PLT
	movl	-60(%rbp), %eax
	cmpl	$2, %eax
	je	.L5
	cmpl	$2, %eax
	jg	.L6
	testl	%eax, %eax
	je	.L7
	cmpl	$1, %eax
	je	.L8
	jmp	.L6
.L7:
	movq	stdin(%rip), %rax
	leaq	-48(%rbp), %rdx
	leaq	.LC1(%rip), %rcx
	movq	%rcx, %rsi
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_fscanf@PLT
	movl	-52(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	movq	-40(%rbp), %rax
	addq	%rdx, %rax
	movq	(%rax), %rcx
	movl	-52(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-32(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %edx
	addl	$1, %edx
	movl	%edx, (%rax)
	movl	(%rax), %eax
	cltq
	salq	$2, %rax
	leaq	(%rcx,%rax), %rdx
	movl	-48(%rbp), %eax
	movl	%eax, (%rdx)
	jmp	.L6
.L8:
	movl	-52(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-32(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	testl	%eax, %eax
	js	.L13
	movl	-52(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	movq	-40(%rbp), %rax
	addq	%rdx, %rax
	movq	(%rax), %rdx
	movl	-52(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	movq	-32(%rbp), %rax
	addq	%rcx, %rax
	movl	(%rax), %eax
	cltq
	salq	$2, %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L13
.L5:
	movl	-52(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-32(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	testl	%eax, %eax
	js	.L6
	movl	-52(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-32(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %edx
	subl	$1, %edx
	movl	%edx, (%rax)
	jmp	.L6
.L13:
	nop
.L6:
	addl	$1, -44(%rbp)
.L4:
	movl	-56(%rbp), %eax
	cmpl	%eax, -44(%rbp)
	jl	.L10
	movl	$0, %eax
	movq	-24(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L12
	call	__stack_chk_fail@PLT
.L12:
	movq	-8(%rbp), %rbx
	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
	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
	.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:

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


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>

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

```

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
	pushq	%rbx
	subq	$56, %rsp
	.cfi_offset 3, -24
	movq	%fs:40, %rax
	movq	%rax, -24(%rbp)
	xorl	%eax, %eax
	movq	stdin(%rip), %rax
	leaq	-56(%rbp), %rcx
	leaq	-64(%rbp), %rdx
	leaq	.LC0(%rip), %rsi
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_fscanf@PLT
	movl	-64(%rbp), %eax
	cltq
	salq	$3, %rax
	movq	%rax, %rdi
	call	malloc@PLT
	movq	%rax, -40(%rbp)
	movl	-64(%rbp), %eax
	cltq
	salq	$2, %rax
	movq	%rax, %rdi
	call	malloc@PLT
	movq	%rax, -32(%rbp)
	movl	$0, -44(%rbp)
	jmp	.L2
.L3:
	movl	-56(%rbp), %eax
	cltq
	salq	$2, %rax
	movl	-44(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,8), %rcx
	movq	-40(%rbp), %rdx
	leaq	(%rcx,%rdx), %rbx
	movq	%rax, %rdi
	call	malloc@PLT
	movq	%rax, (%rbx)
	movl	-44(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-32(%rbp), %rax
	addq	%rdx, %rax
	movl	$-1, (%rax)
	addl	$1, -44(%rbp)
.L2:
	movl	-64(%rbp), %eax
	cmpl	%eax, -44(%rbp)
	jl	.L3
	movl	$0, -44(%rbp)
	jmp	.L4
.L10:
	movq	stdin(%rip), %rax
	leaq	-52(%rbp), %rcx
	leaq	-60(%rbp), %rdx
	leaq	.LC0(%rip), %rsi
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_fscanf@PLT
	movl	-60(%rbp), %eax
	cmpl	$2, %eax
	je	.L5
	cmpl	$2, %eax
	jg	.L6
	testl	%eax, %eax
	je	.L7
	cmpl	$1, %eax
	je	.L8
	jmp	.L6
.L7:
	movq	stdin(%rip), %rax
	leaq	-48(%rbp), %rdx
	leaq	.LC1(%rip), %rcx
	movq	%rcx, %rsi
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_fscanf@PLT
	movl	-52(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	movq	-40(%rbp), %rax
	addq	%rdx, %rax
	movq	(%rax), %rcx
	movl	-52(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-32(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %edx
	addl	$1, %edx
	movl	%edx, (%rax)
	movl	(%rax), %eax
	cltq
	salq	$2, %rax
	leaq	(%rcx,%rax), %rdx
	movl	-48(%rbp), %eax
	movl	%eax, (%rdx)
	jmp	.L6
.L8:
	movl	-52(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-32(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	testl	%eax, %eax
	js	.L13
	movl	-52(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	movq	-40(%rbp), %rax
	addq	%rdx, %rax
	movq	(%rax), %rdx
	movl	-52(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	movq	-32(%rbp), %rax
	addq	%rcx, %rax
	movl	(%rax), %eax
	cltq
	salq	$2, %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L13
.L5:
	movl	-52(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-32(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	testl	%eax, %eax
	js	.L6
	movl	-52(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-32(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %edx
	subl	$1, %edx
	movl	%edx, (%rax)
	jmp	.L6
.L13:
	nop
.L6:
	addl	$1, -44(%rbp)
.L4:
	movl	-56(%rbp), %eax
	cmpl	%eax, -44(%rbp)
	jl	.L10
	movl	$0, %eax
	movq	-24(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L12
	call	__stack_chk_fail@PLT
.L12:
	movq	-8(%rbp), %rbx
	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
	pushq	%rbx
	subq	$56, %rsp
	.cfi_offset 3, -24
	movq	%fs:40, %rax
	movq	%rax, -24(%rbp)
	xorl	%eax, %eax
	movq	stdin(%rip), %rax
	leaq	-56(%rbp), %rcx
	leaq	-64(%rbp), %rdx
	leaq	.LC0(%rip), %rsi
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_fscanf@PLT
	movl	-64(%rbp), %eax
	cltq
	salq	$3, %rax
	movq	%rax, %rdi
	call	malloc@PLT
	movq	%rax, -40(%rbp)
	movl	-64(%rbp), %eax
	cltq
	salq	$2, %rax
	movq	%rax, %rdi
	call	malloc@PLT
	movq	%rax, -32(%rbp)
	movl	$0, -44(%rbp)
	jmp	.L2
.L3:
	movl	-56(%rbp), %eax
	cltq
	salq	$2, %rax
	movl	-44(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,8), %rcx
	movq	-40(%rbp), %rdx
	leaq	(%rcx,%rdx), %rbx
	movq	%rax, %rdi
	call	malloc@PLT
	movq	%rax, (%rbx)
	movl	-44(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-32(%rbp), %rax
	addq	%rdx, %rax
	movl	$-1, (%rax)
	addl	$1, -44(%rbp)
.L2:
	movl	-64(%rbp), %eax
	cmpl	%eax, -44(%rbp)
	jl	.L3
	movl	$0, -44(%rbp)
	jmp	.L4
.L10:
	movq	stdin(%rip), %rax
	leaq	-52(%rbp), %rcx
	leaq	-60(%rbp), %rdx
	leaq	.LC0(%rip), %rsi
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_fscanf@PLT
	movl	-60(%rbp), %eax
	cmpl	$2, %eax
	je	.L5
	cmpl	$2, %eax
	jg	.L6
	testl	%eax, %eax
	je	.L7
	cmpl	$1, %eax
	je	.L8
	jmp	.L6
.L7:
	movq	stdin(%rip), %rax
	leaq	-48(%rbp), %rdx
	leaq	.LC1(%rip), %rcx
	movq	%rcx, %rsi
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_fscanf@PLT
	movl	-52(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	movq	-40(%rbp), %rax
	addq	%rdx, %rax
	movq	(%rax), %rcx
	movl	-52(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-32(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %edx
	addl	$1, %edx
	movl	%edx, (%rax)
	movl	(%rax), %eax
	cltq
	salq	$2, %rax
	leaq	(%rcx,%rax), %rdx
	movl	-48(%rbp), %eax
	movl	%eax, (%rdx)
	jmp	.L6
.L8:
	movl	-52(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-32(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	testl	%eax, %eax
	js	.L13
	movl	-52(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	movq	-40(%rbp), %rax
	addq	%rdx, %rax
	movq	(%rax), %rdx
	movl	-52(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	movq	-32(%rbp), %rax
	addq	%rcx, %rax
	movl	(%rax), %eax
	cltq
	salq	$2, %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L13
.L5:
	movl	-52(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-32(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	testl	%eax, %eax
	js	.L6
	movl	-52(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-32(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %edx
	subl	$1, %edx
	movl	%edx, (%rax)
	jmp	.L6
.L13:
	nop
.L6:
	addl	$1, -44(%rbp)
.L4:
	movl	-56(%rbp), %eax
	cmpl	%eax, -44(%rbp)
	jl	.L10
	movl	$0, %eax
	movq	-24(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L12
	call	__stack_chk_fail@PLT
.L12:
	movq	-8(%rbp), %rbx
	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:
