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>

// 関数ポインタ定義
typedef void(*FUNC_POINTER) (int*, int*);

// スタックを実装、操作は以下の３つでそれぞれ0,1,2で操作の種類を指定
// ・push(t, x) : St に整数xを挿入する。
// ・top(t) : Stから次に取り出される要素を報告する。ただし、Stが空の場合は何もしない。
// ・pop(t) : Stから要素を取り出し削除する。ただし、Stが空の場合は何もしない。

void push(int* piData, int* iElementNum);
void top(int* piData, int* iElementNum);
void pop(int* piData, int* iElementNum);

int main()
{
	int iInputN;
	int iInputQ;
	int iInputT;
	int iInputOrder;
	int** ppiData;
	int* iElementNum;
	int iCnt;

	// 関数ポインタ
	FUNC_POINTER pFunc[] = {
		push,
		top,
		pop
	};

	scanf("%d %d", &iInputN, &iInputQ);

	// 初期化
	ppiData = (int**)malloc(sizeof(int*) * iInputN);
	for (iCnt = 0; iCnt < iInputN; iCnt++)
	{
		ppiData[iCnt] = (int*)malloc(sizeof(int) * iInputQ);
	}
	iElementNum = (int*)calloc(iInputN, sizeof(int));

	for (iCnt = 0; iCnt < iInputQ; iCnt++)
	{
		scanf("%d %d", &iInputOrder, &iInputT);
		
		if (iInputOrder == 0 || iInputOrder == 1 || iInputOrder == 2)
		{
			pFunc[iInputOrder](ppiData[iInputT], &iElementNum[iInputT]);
		}
	}

	return 0;
}

// スタックに整数挿入
void push(int* piData, int* iElementNum)
{
	scanf("%d", &piData[*iElementNum]);
	(*iElementNum)++;

	return;
}

// 次に取り出される要素を出力
void top(int* piData, int* iElementNum)
{
	if (*iElementNum <= 0)
	{
		return;
	}
	printf("%d\n", piData[(*iElementNum) - 1]);
	return;
}

// 要素を取り出して削除
void pop(int* piData, int* iElementNum)
{
	if (*iElementNum <= 0)
	{
		return;
	}
	(*iElementNum)--;

	return;
}
```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%d %d"
	.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	$88, %rsp
	.cfi_offset 3, -24
	movq	%fs:40, %rax
	movq	%rax, -24(%rbp)
	xorl	%eax, %eax
	leaq	push(%rip), %rax
	movq	%rax, -48(%rbp)
	leaq	top(%rip), %rax
	movq	%rax, -40(%rbp)
	leaq	pop(%rip), %rax
	movq	%rax, -32(%rbp)
	leaq	-80(%rbp), %rdx
	leaq	-84(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-84(%rbp), %eax
	cltq
	salq	$3, %rax
	movq	%rax, %rdi
	call	malloc@PLT
	movq	%rax, -64(%rbp)
	movl	$0, -68(%rbp)
	jmp	.L2
.L3:
	movl	-80(%rbp), %eax
	cltq
	salq	$2, %rax
	movl	-68(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,8), %rcx
	movq	-64(%rbp), %rdx
	leaq	(%rcx,%rdx), %rbx
	movq	%rax, %rdi
	call	malloc@PLT
	movq	%rax, (%rbx)
	addl	$1, -68(%rbp)
.L2:
	movl	-84(%rbp), %eax
	cmpl	%eax, -68(%rbp)
	jl	.L3
	movl	-84(%rbp), %eax
	cltq
	movl	$4, %esi
	movq	%rax, %rdi
	call	calloc@PLT
	movq	%rax, -56(%rbp)
	movl	$0, -68(%rbp)
	jmp	.L4
.L7:
	leaq	-76(%rbp), %rdx
	leaq	-72(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-72(%rbp), %eax
	testl	%eax, %eax
	je	.L5
	movl	-72(%rbp), %eax
	cmpl	$1, %eax
	je	.L5
	movl	-72(%rbp), %eax
	cmpl	$2, %eax
	jne	.L6
.L5:
	movl	-72(%rbp), %eax
	cltq
	movq	-48(%rbp,%rax,8), %rdx
	movl	-76(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	movq	-56(%rbp), %rax
	addq	%rax, %rcx
	movl	-76(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rsi
	movq	-64(%rbp), %rax
	addq	%rsi, %rax
	movq	(%rax), %rax
	movq	%rcx, %rsi
	movq	%rax, %rdi
	call	*%rdx
.L6:
	addl	$1, -68(%rbp)
.L4:
	movl	-80(%rbp), %eax
	cmpl	%eax, -68(%rbp)
	jl	.L7
	movl	$0, %eax
	movq	-24(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L9
	call	__stack_chk_fail@PLT
.L9:
	movq	-8(%rbp), %rbx
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	main, .-main
	.section	.rodata
.LC1:
	.string	"%d"
	.text
	.globl	push
	.type	push, @function
push:
.LFB7:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$16, %rsp
	movq	%rdi, -8(%rbp)
	movq	%rsi, -16(%rbp)
	movq	-16(%rbp), %rax
	movl	(%rax), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-8(%rbp), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movq	-16(%rbp), %rax
	movl	(%rax), %eax
	leal	1(%rax), %edx
	movq	-16(%rbp), %rax
	movl	%edx, (%rax)
	nop
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.size	push, .-push
	.section	.rodata
.LC2:
	.string	"%d\n"
	.text
	.globl	top
	.type	top, @function
top:
.LFB8:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$16, %rsp
	movq	%rdi, -8(%rbp)
	movq	%rsi, -16(%rbp)
	movq	-16(%rbp), %rax
	movl	(%rax), %eax
	testl	%eax, %eax
	jle	.L15
	movq	-16(%rbp), %rax
	movl	(%rax), %eax
	cltq
	salq	$2, %rax
	leaq	-4(%rax), %rdx
	movq	-8(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L12
.L15:
	nop
.L12:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE8:
	.size	top, .-top
	.globl	pop
	.type	pop, @function
pop:
.LFB9:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movq	%rdi, -8(%rbp)
	movq	%rsi, -16(%rbp)
	movq	-16(%rbp), %rax
	movl	(%rax), %eax
	testl	%eax, %eax
	jle	.L19
	movq	-16(%rbp), %rax
	movl	(%rax), %eax
	leal	-1(%rax), %edx
	movq	-16(%rbp), %rax
	movl	%edx, (%rax)
	jmp	.L16
.L19:
	nop
.L16:
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE9:
	.size	pop, .-pop
	.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
	.p2align 4
	.globl	pop
	.type	pop, @function
pop:
.LFB42:
	.cfi_startproc
	endbr64
	movl	(%rsi), %eax
	testl	%eax, %eax
	jle	.L1
	subl	$1, %eax
	movl	%eax, (%rsi)
.L1:
	ret
	.cfi_endproc
.LFE42:
	.size	pop, .-pop
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d"
	.text
	.p2align 4
	.globl	push
	.type	push, @function
push:
.LFB40:
	.cfi_startproc
	endbr64
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset 3, -16
	movslq	(%rsi), %rax
	movq	%rsi, %rbx
	leaq	(%rdi,%rax,4), %rsi
	leaq	.LC0(%rip), %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	addl	$1, (%rbx)
	popq	%rbx
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE40:
	.size	push, .-push
	.section	.rodata.str1.1
.LC1:
	.string	"%d\n"
	.text
	.p2align 4
	.globl	top
	.type	top, @function
top:
.LFB41:
	.cfi_startproc
	endbr64
	movslq	(%rsi), %rax
	testl	%eax, %eax
	jle	.L6
	movl	-4(%rdi,%rax,4), %edx
	leaq	.LC1(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	jmp	__printf_chk@PLT
	.p2align 4,,10
	.p2align 3
.L6:
	ret
	.cfi_endproc
.LFE41:
	.size	top, .-top
	.section	.rodata.str1.1
.LC2:
	.string	"%d %d"
	.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
	leaq	push(%rip), %rcx
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	movq	%rcx, %xmm0
	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	.LC2(%rip), %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	movq	%rbp, %rdi
	subq	$72, %rsp
	.cfi_def_cfa_offset 128
	movq	%fs:40, %rax
	movq	%rax, 56(%rsp)
	leaq	top(%rip), %rax
	leaq	20(%rsp), %rdx
	leaq	16(%rsp), %rsi
	movq	%rax, %xmm1
	leaq	pop(%rip), %rax
	punpcklqdq	%xmm1, %xmm0
	movq	%rax, 48(%rsp)
	xorl	%eax, %eax
	movaps	%xmm0, 32(%rsp)
	call	__isoc99_scanf@PLT
	movslq	16(%rsp), %r13
	leaq	0(,%r13,8), %rdi
	call	malloc@PLT
	movq	%rax, %r14
	testl	%r13d, %r13d
	jle	.L9
	movslq	20(%rsp), %rbx
	movl	%r13d, %r12d
	movq	%r14, %r15
	leaq	(%r14,%r12,8), %r12
	movl	%ebx, 12(%rsp)
	salq	$2, %rbx
	.p2align 4,,10
	.p2align 3
.L10:
	movq	%rbx, %rdi
	addq	$8, %r15
	call	malloc@PLT
	movq	%rax, -8(%r15)
	cmpq	%r12, %r15
	jne	.L10
.L11:
	movq	%r13, %rdi
	movl	$4, %esi
	leaq	24(%rsp), %r13
	xorl	%ebx, %ebx
	call	calloc@PLT
	leaq	28(%rsp), %r12
	movq	%rax, %r15
	movl	12(%rsp), %eax
	testl	%eax, %eax
	jle	.L15
	.p2align 4,,10
	.p2align 3
.L12:
	movq	%r13, %rdx
	movq	%r12, %rsi
	movq	%rbp, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movslq	28(%rsp), %rax
	cmpl	$2, %eax
	ja	.L13
	movslq	24(%rsp), %rdx
	addl	$1, %ebx
	movq	(%r14,%rdx,8), %rdi
	leaq	(%r15,%rdx,4), %rsi
	call	*32(%rsp,%rax,8)
	cmpl	20(%rsp), %ebx
	jl	.L12
.L15:
	movq	56(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L22
	addq	$72, %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
.L13:
	.cfi_restore_state
	addl	$1, %ebx
	cmpl	%ebx, 20(%rsp)
	jg	.L12
	jmp	.L15
.L9:
	movl	20(%rsp), %eax
	movl	%eax, 12(%rsp)
	jmp	.L11
.L22:
	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
	.p2align 4
	.globl	pop
	.type	pop, @function
pop:
.LFB42:
	.cfi_startproc
	endbr64
	movl	(%rsi), %eax
	testl	%eax, %eax
	jle	.L1
	subl	$1, %eax
	movl	%eax, (%rsi)
.L1:
	ret
	.cfi_endproc
.LFE42:
	.size	pop, .-pop
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d"
	.text
	.p2align 4
	.globl	push
	.type	push, @function
push:
.LFB40:
	.cfi_startproc
	endbr64
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset 3, -16
	movslq	(%rsi), %rax
	movq	%rsi, %rbx
	leaq	(%rdi,%rax,4), %rsi
	leaq	.LC0(%rip), %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	addl	$1, (%rbx)
	popq	%rbx
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE40:
	.size	push, .-push
	.section	.rodata.str1.1
.LC1:
	.string	"%d\n"
	.text
	.p2align 4
	.globl	top
	.type	top, @function
top:
.LFB41:
	.cfi_startproc
	endbr64
	movslq	(%rsi), %rax
	testl	%eax, %eax
	jle	.L6
	movl	-4(%rdi,%rax,4), %edx
	leaq	.LC1(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	jmp	__printf_chk@PLT
	.p2align 4,,10
	.p2align 3
.L6:
	ret
	.cfi_endproc
.LFE41:
	.size	top, .-top
	.section	.rodata.str1.1
.LC2:
	.string	"%d %d"
	.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
	leaq	push(%rip), %rcx
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	movq	%rcx, %xmm0
	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	.LC2(%rip), %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	movq	%rbp, %rdi
	subq	$72, %rsp
	.cfi_def_cfa_offset 128
	movq	%fs:40, %rax
	movq	%rax, 56(%rsp)
	leaq	top(%rip), %rax
	leaq	20(%rsp), %rdx
	leaq	16(%rsp), %rsi
	movq	%rax, %xmm1
	leaq	pop(%rip), %rax
	punpcklqdq	%xmm1, %xmm0
	movq	%rax, 48(%rsp)
	xorl	%eax, %eax
	movaps	%xmm0, 32(%rsp)
	call	__isoc99_scanf@PLT
	movslq	16(%rsp), %r13
	leaq	0(,%r13,8), %rdi
	call	malloc@PLT
	movq	%rax, %r14
	testl	%r13d, %r13d
	jle	.L9
	movslq	20(%rsp), %rbx
	movl	%r13d, %r12d
	movq	%r14, %r15
	leaq	(%r14,%r12,8), %r12
	movl	%ebx, 12(%rsp)
	salq	$2, %rbx
	.p2align 4,,10
	.p2align 3
.L10:
	movq	%rbx, %rdi
	addq	$8, %r15
	call	malloc@PLT
	movq	%rax, -8(%r15)
	cmpq	%r12, %r15
	jne	.L10
.L11:
	movq	%r13, %rdi
	movl	$4, %esi
	leaq	24(%rsp), %r13
	xorl	%ebx, %ebx
	call	calloc@PLT
	leaq	28(%rsp), %r12
	movq	%rax, %r15
	movl	12(%rsp), %eax
	testl	%eax, %eax
	jle	.L15
	.p2align 4,,10
	.p2align 3
.L12:
	movq	%r13, %rdx
	movq	%r12, %rsi
	movq	%rbp, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movslq	28(%rsp), %rax
	cmpl	$2, %eax
	ja	.L13
	movslq	24(%rsp), %rdx
	addl	$1, %ebx
	movq	(%r14,%rdx,8), %rdi
	leaq	(%r15,%rdx,4), %rsi
	call	*32(%rsp,%rax,8)
	cmpl	20(%rsp), %ebx
	jl	.L12
.L15:
	movq	56(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L22
	addq	$72, %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
.L13:
	.cfi_restore_state
	addl	$1, %ebx
	cmpl	%ebx, 20(%rsp)
	jg	.L12
	jmp	.L15
.L9:
	movl	20(%rsp), %eax
	movl	%eax, 12(%rsp)
	jmp	.L11
.L22:
	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>

// 関数ポインタ定義
typedef void(*FUNC_POINTER) (int*, int*);

// スタックを実装、操作は以下の３つでそれぞれ0,1,2で操作の種類を指定
// ・push(t, x) : St に整数xを挿入する。
// ・top(t) : Stから次に取り出される要素を報告する。ただし、Stが空の場合は何もしない。
// ・pop(t) : Stから要素を取り出し削除する。ただし、Stが空の場合は何もしない。

void push(int* piData, int* iElementNum);
void top(int* piData, int* iElementNum);
void pop(int* piData, int* iElementNum);

int main()
{
	int iInputN;
	int iInputQ;
	int iInputT;
	int iInputOrder;
	int** ppiData;
	int* iElementNum;
	int iCnt;

	// 関数ポインタ
	FUNC_POINTER pFunc[] = {
		push,
		top,
		pop
	};

	scanf("%d %d", &iInputN, &iInputQ);

	// 初期化
	ppiData = (int**)malloc(sizeof(int*) * iInputN);
	for (iCnt = 0; iCnt < iInputN; iCnt++)
	{
		ppiData[iCnt] = (int*)malloc(sizeof(int) * iInputQ);
	}
	iElementNum = (int*)calloc(iInputN, sizeof(int));

	for (iCnt = 0; iCnt < iInputQ; iCnt++)
	{
		scanf("%d %d", &iInputOrder, &iInputT);
		
		if (iInputOrder == 0 || iInputOrder == 1 || iInputOrder == 2)
		{
			pFunc[iInputOrder](ppiData[iInputT], &iElementNum[iInputT]);
		}
	}

	return 0;
}

// スタックに整数挿入
void push(int* piData, int* iElementNum)
{
	scanf("%d", &piData[*iElementNum]);
	(*iElementNum)++;

	return;
}

// 次に取り出される要素を出力
void top(int* piData, int* iElementNum)
{
	if (*iElementNum <= 0)
	{
		return;
	}
	printf("%d\n", piData[(*iElementNum) - 1]);
	return;
}

// 要素を取り出して削除
void pop(int* piData, int* iElementNum)
{
	if (*iElementNum <= 0)
	{
		return;
	}
	(*iElementNum)--;

	return;
}

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>

// 関数ポインタ定義
typedef void(*FUNC_POINTER) (int*, int*);

// スタックを実装、操作は以下の３つでそれぞれ0,1,2で操作の種類を指定
// ・push(t, x) : St に整数xを挿入する。
// ・top(t) : Stから次に取り出される要素を報告する。ただし、Stが空の場合は何もしない。
// ・pop(t) : Stから要素を取り出し削除する。ただし、Stが空の場合は何もしない。

void push(int* piData, int* iElementNum);
void top(int* piData, int* iElementNum);
void pop(int* piData, int* iElementNum);

int main()
{
	int iInputN;
	int iInputQ;
	int iInputT;
	int iInputOrder;
	int** ppiData;
	int* iElementNum;
	int iCnt;

	// 関数ポインタ
	FUNC_POINTER pFunc[] = {
		push,
		top,
		pop
	};

	scanf("%d %d", &iInputN, &iInputQ);

	// 初期化
	ppiData = (int**)malloc(sizeof(int*) * iInputN);
	for (iCnt = 0; iCnt < iInputN; iCnt++)
	{
		ppiData[iCnt] = (int*)malloc(sizeof(int) * iInputQ);
	}
	iElementNum = (int*)calloc(iInputN, sizeof(int));

	for (iCnt = 0; iCnt < iInputQ; iCnt++)
	{
		scanf("%d %d", &iInputOrder, &iInputT);
		
		if (iInputOrder == 0 || iInputOrder == 1 || iInputOrder == 2)
		{
			pFunc[iInputOrder](ppiData[iInputT], &iElementNum[iInputT]);
		}
	}

	return 0;
}

// スタックに整数挿入
void push(int* piData, int* iElementNum)
{
	scanf("%d", &piData[*iElementNum]);
	(*iElementNum)++;

	return;
}

// 次に取り出される要素を出力
void top(int* piData, int* iElementNum)
{
	if (*iElementNum <= 0)
	{
		return;
	}
	printf("%d\n", piData[(*iElementNum) - 1]);
	return;
}

// 要素を取り出して削除
void pop(int* piData, int* iElementNum)
{
	if (*iElementNum <= 0)
	{
		return;
	}
	(*iElementNum)--;

	return;
}
```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%d %d"
	.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	$88, %rsp
	.cfi_offset 3, -24
	movq	%fs:40, %rax
	movq	%rax, -24(%rbp)
	xorl	%eax, %eax
	leaq	push(%rip), %rax
	movq	%rax, -48(%rbp)
	leaq	top(%rip), %rax
	movq	%rax, -40(%rbp)
	leaq	pop(%rip), %rax
	movq	%rax, -32(%rbp)
	leaq	-80(%rbp), %rdx
	leaq	-84(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-84(%rbp), %eax
	cltq
	salq	$3, %rax
	movq	%rax, %rdi
	call	malloc@PLT
	movq	%rax, -64(%rbp)
	movl	$0, -68(%rbp)
	jmp	.L2
.L3:
	movl	-80(%rbp), %eax
	cltq
	salq	$2, %rax
	movl	-68(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,8), %rcx
	movq	-64(%rbp), %rdx
	leaq	(%rcx,%rdx), %rbx
	movq	%rax, %rdi
	call	malloc@PLT
	movq	%rax, (%rbx)
	addl	$1, -68(%rbp)
.L2:
	movl	-84(%rbp), %eax
	cmpl	%eax, -68(%rbp)
	jl	.L3
	movl	-84(%rbp), %eax
	cltq
	movl	$4, %esi
	movq	%rax, %rdi
	call	calloc@PLT
	movq	%rax, -56(%rbp)
	movl	$0, -68(%rbp)
	jmp	.L4
.L7:
	leaq	-76(%rbp), %rdx
	leaq	-72(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-72(%rbp), %eax
	testl	%eax, %eax
	je	.L5
	movl	-72(%rbp), %eax
	cmpl	$1, %eax
	je	.L5
	movl	-72(%rbp), %eax
	cmpl	$2, %eax
	jne	.L6
.L5:
	movl	-72(%rbp), %eax
	cltq
	movq	-48(%rbp,%rax,8), %rdx
	movl	-76(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	movq	-56(%rbp), %rax
	addq	%rax, %rcx
	movl	-76(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rsi
	movq	-64(%rbp), %rax
	addq	%rsi, %rax
	movq	(%rax), %rax
	movq	%rcx, %rsi
	movq	%rax, %rdi
	call	*%rdx
.L6:
	addl	$1, -68(%rbp)
.L4:
	movl	-80(%rbp), %eax
	cmpl	%eax, -68(%rbp)
	jl	.L7
	movl	$0, %eax
	movq	-24(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L9
	call	__stack_chk_fail@PLT
.L9:
	movq	-8(%rbp), %rbx
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	main, .-main
	.section	.rodata
.LC1:
	.string	"%d"
	.text
	.globl	push
	.type	push, @function
push:
.LFB7:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$16, %rsp
	movq	%rdi, -8(%rbp)
	movq	%rsi, -16(%rbp)
	movq	-16(%rbp), %rax
	movl	(%rax), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-8(%rbp), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movq	-16(%rbp), %rax
	movl	(%rax), %eax
	leal	1(%rax), %edx
	movq	-16(%rbp), %rax
	movl	%edx, (%rax)
	nop
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.size	push, .-push
	.section	.rodata
.LC2:
	.string	"%d\n"
	.text
	.globl	top
	.type	top, @function
top:
.LFB8:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$16, %rsp
	movq	%rdi, -8(%rbp)
	movq	%rsi, -16(%rbp)
	movq	-16(%rbp), %rax
	movl	(%rax), %eax
	testl	%eax, %eax
	jle	.L15
	movq	-16(%rbp), %rax
	movl	(%rax), %eax
	cltq
	salq	$2, %rax
	leaq	-4(%rax), %rdx
	movq	-8(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L12
.L15:
	nop
.L12:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE8:
	.size	top, .-top
	.globl	pop
	.type	pop, @function
pop:
.LFB9:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movq	%rdi, -8(%rbp)
	movq	%rsi, -16(%rbp)
	movq	-16(%rbp), %rax
	movl	(%rax), %eax
	testl	%eax, %eax
	jle	.L19
	movq	-16(%rbp), %rax
	movl	(%rax), %eax
	leal	-1(%rax), %edx
	movq	-16(%rbp), %rax
	movl	%edx, (%rax)
	jmp	.L16
.L19:
	nop
.L16:
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE9:
	.size	pop, .-pop
	.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"
	.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	$88, %rsp
	.cfi_offset 3, -24
	movq	%fs:40, %rax
	movq	%rax, -24(%rbp)
	xorl	%eax, %eax
	leaq	push(%rip), %rax
	movq	%rax, -48(%rbp)
	leaq	top(%rip), %rax
	movq	%rax, -40(%rbp)
	leaq	pop(%rip), %rax
	movq	%rax, -32(%rbp)
	leaq	-80(%rbp), %rdx
	leaq	-84(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-84(%rbp), %eax
	cltq
	salq	$3, %rax
	movq	%rax, %rdi
	call	malloc@PLT
	movq	%rax, -64(%rbp)
	movl	$0, -68(%rbp)
	jmp	.L2
.L3:
	movl	-80(%rbp), %eax
	cltq
	salq	$2, %rax
	movl	-68(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,8), %rcx
	movq	-64(%rbp), %rdx
	leaq	(%rcx,%rdx), %rbx
	movq	%rax, %rdi
	call	malloc@PLT
	movq	%rax, (%rbx)
	addl	$1, -68(%rbp)
.L2:
	movl	-84(%rbp), %eax
	cmpl	%eax, -68(%rbp)
	jl	.L3
	movl	-84(%rbp), %eax
	cltq
	movl	$4, %esi
	movq	%rax, %rdi
	call	calloc@PLT
	movq	%rax, -56(%rbp)
	movl	$0, -68(%rbp)
	jmp	.L4
.L7:
	leaq	-76(%rbp), %rdx
	leaq	-72(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-72(%rbp), %eax
	testl	%eax, %eax
	je	.L5
	movl	-72(%rbp), %eax
	cmpl	$1, %eax
	je	.L5
	movl	-72(%rbp), %eax
	cmpl	$2, %eax
	jne	.L6
.L5:
	movl	-72(%rbp), %eax
	cltq
	movq	-48(%rbp,%rax,8), %rdx
	movl	-76(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	movq	-56(%rbp), %rax
	addq	%rax, %rcx
	movl	-76(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rsi
	movq	-64(%rbp), %rax
	addq	%rsi, %rax
	movq	(%rax), %rax
	movq	%rcx, %rsi
	movq	%rax, %rdi
	call	*%rdx
.L6:
	addl	$1, -68(%rbp)
.L4:
	movl	-80(%rbp), %eax
	cmpl	%eax, -68(%rbp)
	jl	.L7
	movl	$0, %eax
	movq	-24(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L9
	call	__stack_chk_fail@PLT
.L9:
	movq	-8(%rbp), %rbx
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	main, .-main
	.section	.rodata
.LC1:
	.string	"%d"
	.text
	.globl	push
	.type	push, @function
push:
.LFB7:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$16, %rsp
	movq	%rdi, -8(%rbp)
	movq	%rsi, -16(%rbp)
	movq	-16(%rbp), %rax
	movl	(%rax), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-8(%rbp), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movq	-16(%rbp), %rax
	movl	(%rax), %eax
	leal	1(%rax), %edx
	movq	-16(%rbp), %rax
	movl	%edx, (%rax)
	nop
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.size	push, .-push
	.section	.rodata
.LC2:
	.string	"%d\n"
	.text
	.globl	top
	.type	top, @function
top:
.LFB8:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$16, %rsp
	movq	%rdi, -8(%rbp)
	movq	%rsi, -16(%rbp)
	movq	-16(%rbp), %rax
	movl	(%rax), %eax
	testl	%eax, %eax
	jle	.L15
	movq	-16(%rbp), %rax
	movl	(%rax), %eax
	cltq
	salq	$2, %rax
	leaq	-4(%rax), %rdx
	movq	-8(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L12
.L15:
	nop
.L12:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE8:
	.size	top, .-top
	.globl	pop
	.type	pop, @function
pop:
.LFB9:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movq	%rdi, -8(%rbp)
	movq	%rsi, -16(%rbp)
	movq	-16(%rbp), %rax
	movl	(%rax), %eax
	testl	%eax, %eax
	jle	.L19
	movq	-16(%rbp), %rax
	movl	(%rax), %eax
	leal	-1(%rax), %edx
	movq	-16(%rbp), %rax
	movl	%edx, (%rax)
	jmp	.L16
.L19:
	nop
.L16:
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE9:
	.size	pop, .-pop
	.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:
