Given the following C code and unoptimized assembly code, your task is to generate highly optimized x86-64 assembly code.
C Code:

```c
/*
 * FileName:     stack_model
 * CreatedDate:  2020-05-23 23:19:48 +0900
 * LastModified: 2020-05-23 23:31:24 +0900
 */

#include<stdio.h>
#include<stdlib.h>
static const int MAX_N = 1000;

typedef struct Node{
    int data;
    struct Node *under;
}node_str;
typedef struct Stack{
    node_str *top;
}stack_str;

stack_str *CreateStack(){
    stack_str *S = malloc(sizeof(stack_str));
    S->top = NULL;
    return S;
}
void push(stack_str *S, int x){
    if(S->top == NULL){
	S->top = malloc(sizeof(node_str));
	S->top->data = x;
	S->top->under = NULL;
    }else{
	node_str *bf = malloc(sizeof(node_str));
	bf->under = S->top;
	bf->data = x;
	S->top = bf;
    }
}
void top(stack_str *S){
    if(S->top == NULL) return;
    printf("%d\n", S->top->data);
}
void pop(stack_str *S){
    if(S->top == NULL) return;
    if(S->top->under == NULL){
	free(S->top);
	S->top = NULL;
	return;
    }
    node_str *bf = S->top->under;
    free(S->top);
    S->top = bf;
}
void deleteStack(stack_str *S){
    if(S->top == NULL) return;
    node_str *cur = S->top;
    for(;;){
	if(cur->under == NULL){
	    free(cur);
	    break;
        }
	node_str *bf = cur->under;
	free(cur);
	cur = bf;
    }
    free(S);
}

int main(){
    int n, q;
    scanf("%d %d", &n, &q);
    stack_str *S[MAX_N];
    for(int i = 0; i < n; i++) S[i] = CreateStack();
    for(int i = 0; i < q; i++){
	int op, t;
	scanf("%d %d", &op, &t);
	if(op == 0){
	    int x;
	    scanf("%d", &x);
	    push(S[t], x);
	}else if(op == 1){
	    top(S[t]);
	}else if(op == 2){
	    pop(S[t]);
	}
    }
    for(int i = 0; i < n; i++) deleteStack(S[i]);
    return 0;
}

```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
	.align 4
	.type	MAX_N, @object
	.size	MAX_N, 4
MAX_N:
	.long	1000
	.text
	.globl	CreateStack
	.type	CreateStack, @function
CreateStack:
.LFB6:
	.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
	movl	$8, %edi
	call	malloc@PLT
	movq	%rax, -8(%rbp)
	movq	-8(%rbp), %rax
	movq	$0, (%rax)
	movq	-8(%rbp), %rax
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	CreateStack, .-CreateStack
	.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	$32, %rsp
	movq	%rdi, -24(%rbp)
	movl	%esi, -28(%rbp)
	movq	-24(%rbp), %rax
	movq	(%rax), %rax
	testq	%rax, %rax
	jne	.L4
	movl	$16, %edi
	call	malloc@PLT
	movq	%rax, %rdx
	movq	-24(%rbp), %rax
	movq	%rdx, (%rax)
	movq	-24(%rbp), %rax
	movq	(%rax), %rax
	movl	-28(%rbp), %edx
	movl	%edx, (%rax)
	movq	-24(%rbp), %rax
	movq	(%rax), %rax
	movq	$0, 8(%rax)
	jmp	.L6
.L4:
	movl	$16, %edi
	call	malloc@PLT
	movq	%rax, -8(%rbp)
	movq	-24(%rbp), %rax
	movq	(%rax), %rdx
	movq	-8(%rbp), %rax
	movq	%rdx, 8(%rax)
	movq	-8(%rbp), %rax
	movl	-28(%rbp), %edx
	movl	%edx, (%rax)
	movq	-24(%rbp), %rax
	movq	-8(%rbp), %rdx
	movq	%rdx, (%rax)
.L6:
	nop
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.size	push, .-push
	.section	.rodata
.LC0:
	.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	-8(%rbp), %rax
	movq	(%rax), %rax
	testq	%rax, %rax
	je	.L10
	movq	-8(%rbp), %rax
	movq	(%rax), %rax
	movl	(%rax), %eax
	movl	%eax, %esi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L7
.L10:
	nop
.L7:
	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
	subq	$32, %rsp
	movq	%rdi, -24(%rbp)
	movq	-24(%rbp), %rax
	movq	(%rax), %rax
	testq	%rax, %rax
	je	.L15
	movq	-24(%rbp), %rax
	movq	(%rax), %rax
	movq	8(%rax), %rax
	testq	%rax, %rax
	jne	.L14
	movq	-24(%rbp), %rax
	movq	(%rax), %rax
	movq	%rax, %rdi
	call	free@PLT
	movq	-24(%rbp), %rax
	movq	$0, (%rax)
	jmp	.L11
.L14:
	movq	-24(%rbp), %rax
	movq	(%rax), %rax
	movq	8(%rax), %rax
	movq	%rax, -8(%rbp)
	movq	-24(%rbp), %rax
	movq	(%rax), %rax
	movq	%rax, %rdi
	call	free@PLT
	movq	-24(%rbp), %rax
	movq	-8(%rbp), %rdx
	movq	%rdx, (%rax)
	jmp	.L11
.L15:
	nop
.L11:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE9:
	.size	pop, .-pop
	.globl	deleteStack
	.type	deleteStack, @function
deleteStack:
.LFB10:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$32, %rsp
	movq	%rdi, -24(%rbp)
	movq	-24(%rbp), %rax
	movq	(%rax), %rax
	testq	%rax, %rax
	je	.L22
	movq	-24(%rbp), %rax
	movq	(%rax), %rax
	movq	%rax, -16(%rbp)
.L21:
	movq	-16(%rbp), %rax
	movq	8(%rax), %rax
	testq	%rax, %rax
	jne	.L19
	movq	-16(%rbp), %rax
	movq	%rax, %rdi
	call	free@PLT
	nop
	movq	-24(%rbp), %rax
	movq	%rax, %rdi
	call	free@PLT
	jmp	.L16
.L19:
	movq	-16(%rbp), %rax
	movq	8(%rax), %rax
	movq	%rax, -8(%rbp)
	movq	-16(%rbp), %rax
	movq	%rax, %rdi
	call	free@PLT
	movq	-8(%rbp), %rax
	movq	%rax, -16(%rbp)
	jmp	.L21
.L22:
	nop
.L16:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE10:
	.size	deleteStack, .-deleteStack
	.section	.rodata
.LC1:
	.string	"%d %d"
.LC2:
	.string	"%d"
	.text
	.globl	main
	.type	main, @function
main:
.LFB11:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	pushq	%r15
	pushq	%r14
	pushq	%r13
	pushq	%r12
	pushq	%rbx
	subq	$72, %rsp
	.cfi_offset 15, -24
	.cfi_offset 14, -32
	.cfi_offset 13, -40
	.cfi_offset 12, -48
	.cfi_offset 3, -56
	movq	%fs:40, %rax
	movq	%rax, -56(%rbp)
	xorl	%eax, %eax
	movq	%rsp, %rax
	movq	%rax, %rbx
	leaq	-100(%rbp), %rdx
	leaq	-104(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$1000, %eax
	cltq
	subq	$1, %rax
	movq	%rax, -72(%rbp)
	movl	$1000, %eax
	cltq
	movq	%rax, %r14
	movl	$0, %r15d
	movl	$1000, %eax
	cltq
	movq	%rax, %r12
	movl	$0, %r13d
	movl	$1000, %eax
	cltq
	leaq	0(,%rax,8), %rdx
	movl	$16, %eax
	subq	$1, %rax
	addq	%rdx, %rax
	movl	$16, %esi
	movl	$0, %edx
	divq	%rsi
	imulq	$16, %rax, %rax
	movq	%rax, %rcx
	andq	$-4096, %rcx
	movq	%rsp, %rdx
	subq	%rcx, %rdx
.L24:
	cmpq	%rdx, %rsp
	je	.L25
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	jmp	.L24
.L25:
	movq	%rax, %rdx
	andl	$4095, %edx
	subq	%rdx, %rsp
	movq	%rax, %rdx
	andl	$4095, %edx
	testq	%rdx, %rdx
	je	.L26
	andl	$4095, %eax
	subq	$8, %rax
	addq	%rsp, %rax
	orq	$0, (%rax)
.L26:
	movq	%rsp, %rax
	addq	$7, %rax
	shrq	$3, %rax
	salq	$3, %rax
	movq	%rax, -64(%rbp)
	movl	$0, -84(%rbp)
	jmp	.L27
.L28:
	movl	$0, %eax
	call	CreateStack
	movq	-64(%rbp), %rdx
	movl	-84(%rbp), %ecx
	movslq	%ecx, %rcx
	movq	%rax, (%rdx,%rcx,8)
	addl	$1, -84(%rbp)
.L27:
	movl	-104(%rbp), %eax
	cmpl	%eax, -84(%rbp)
	jl	.L28
	movl	$0, -80(%rbp)
	jmp	.L29
.L33:
	leaq	-92(%rbp), %rdx
	leaq	-96(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-96(%rbp), %eax
	testl	%eax, %eax
	jne	.L30
	leaq	-88(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-88(%rbp), %edx
	movl	-92(%rbp), %ecx
	movq	-64(%rbp), %rax
	movslq	%ecx, %rcx
	movq	(%rax,%rcx,8), %rax
	movl	%edx, %esi
	movq	%rax, %rdi
	call	push
	jmp	.L31
.L30:
	movl	-96(%rbp), %eax
	cmpl	$1, %eax
	jne	.L32
	movl	-92(%rbp), %edx
	movq	-64(%rbp), %rax
	movslq	%edx, %rdx
	movq	(%rax,%rdx,8), %rax
	movq	%rax, %rdi
	call	top
	jmp	.L31
.L32:
	movl	-96(%rbp), %eax
	cmpl	$2, %eax
	jne	.L31
	movl	-92(%rbp), %edx
	movq	-64(%rbp), %rax
	movslq	%edx, %rdx
	movq	(%rax,%rdx,8), %rax
	movq	%rax, %rdi
	call	pop
.L31:
	addl	$1, -80(%rbp)
.L29:
	movl	-100(%rbp), %eax
	cmpl	%eax, -80(%rbp)
	jl	.L33
	movl	$0, -76(%rbp)
	jmp	.L34
.L35:
	movq	-64(%rbp), %rax
	movl	-76(%rbp), %edx
	movslq	%edx, %rdx
	movq	(%rax,%rdx,8), %rax
	movq	%rax, %rdi
	call	deleteStack
	addl	$1, -76(%rbp)
.L34:
	movl	-104(%rbp), %eax
	cmpl	%eax, -76(%rbp)
	jl	.L35
	movl	$0, %eax
	movq	%rbx, %rsp
	movq	-56(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L37
	call	__stack_chk_fail@PLT
.L37:
	leaq	-40(%rbp), %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE11:
	.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
	.p2align 4
	.globl	CreateStack
	.type	CreateStack, @function
CreateStack:
.LFB39:
	.cfi_startproc
	endbr64
	subq	$8, %rsp
	.cfi_def_cfa_offset 16
	movl	$8, %edi
	call	malloc@PLT
	movq	$0, (%rax)
	addq	$8, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE39:
	.size	CreateStack, .-CreateStack
	.p2align 4
	.globl	push
	.type	push, @function
push:
.LFB40:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	movl	%esi, %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	movq	(%rdi), %r12
	movq	%rdi, %rbx
	movl	$16, %edi
	testq	%r12, %r12
	je	.L8
	call	malloc@PLT
	movq	%r12, 8(%rax)
	movl	%ebp, (%rax)
	movq	%rax, (%rbx)
	popq	%rbx
	.cfi_remember_state
	.cfi_def_cfa_offset 24
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L8:
	.cfi_restore_state
	call	malloc@PLT
	movl	%ebp, (%rax)
	movq	$0, 8(%rax)
	movq	%rax, (%rbx)
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE40:
	.size	push, .-push
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d\n"
	.text
	.p2align 4
	.globl	top
	.type	top, @function
top:
.LFB41:
	.cfi_startproc
	endbr64
	movq	(%rdi), %rax
	testq	%rax, %rax
	je	.L9
	movl	(%rax), %edx
	leaq	.LC0(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	jmp	__printf_chk@PLT
	.p2align 4,,10
	.p2align 3
.L9:
	ret
	.cfi_endproc
.LFE41:
	.size	top, .-top
	.p2align 4
	.globl	pop
	.type	pop, @function
pop:
.LFB42:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	pushq	%rbx
	.cfi_def_cfa_offset 24
	.cfi_offset 3, -24
	movq	%rdi, %rbx
	subq	$8, %rsp
	.cfi_def_cfa_offset 32
	movq	(%rdi), %rdi
	testq	%rdi, %rdi
	je	.L11
	movq	8(%rdi), %rbp
	testq	%rbp, %rbp
	je	.L18
	call	free@PLT
	movq	%rbp, (%rbx)
.L11:
	addq	$8, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 24
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L18:
	.cfi_restore_state
	call	free@PLT
	movq	$0, (%rbx)
	addq	$8, %rsp
	.cfi_def_cfa_offset 24
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE42:
	.size	pop, .-pop
	.p2align 4
	.globl	deleteStack
	.type	deleteStack, @function
deleteStack:
.LFB43:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	movq	%rdi, %r12
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	subq	$8, %rsp
	.cfi_def_cfa_offset 32
	movq	(%rdi), %rdi
	testq	%rdi, %rdi
	je	.L19
	movq	8(%rdi), %rbp
	testq	%rbp, %rbp
	jne	.L21
	jmp	.L28
	.p2align 4,,10
	.p2align 3
.L29:
	movq	%rax, %rbp
.L21:
	call	free@PLT
	movq	8(%rbp), %rax
	movq	%rbp, %rdi
	testq	%rax, %rax
	jne	.L29
.L22:
	movq	%rbp, %rdi
	call	free@PLT
	addq	$8, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 24
	movq	%r12, %rdi
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	jmp	free@PLT
	.p2align 4,,10
	.p2align 3
.L19:
	.cfi_restore_state
	addq	$8, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 24
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L28:
	.cfi_restore_state
	movq	%rdi, %rbp
	jmp	.L22
	.cfi_endproc
.LFE43:
	.size	deleteStack, .-deleteStack
	.section	.rodata.str1.1
.LC1:
	.string	"%d %d"
.LC2:
	.string	"%d"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB44:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	pushq	%r15
	pushq	%r14
	leaq	-72(%rbp), %rdx
	leaq	-76(%rbp), %rsi
	pushq	%r13
	.cfi_offset 15, -24
	.cfi_offset 14, -32
	.cfi_offset 13, -40
	leaq	.LC1(%rip), %r13
	pushq	%r12
	movq	%r13, %rdi
	pushq	%rbx
	subq	$72, %rsp
	.cfi_offset 12, -48
	.cfi_offset 3, -56
	movq	%fs:40, %rax
	movq	%rax, -56(%rbp)
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	leaq	-4096(%rsp), %rax
	cmpq	%rax, %rsp
	je	.L32
.L67:
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	cmpq	%rax, %rsp
	jne	.L67
.L32:
	subq	$3904, %rsp
	orq	$0, 3896(%rsp)
	movl	-76(%rbp), %eax
	movq	%rsp, %r12
	testl	%eax, %eax
	jle	.L34
	movq	%r12, %r14
	leaq	(%r12,%rax,8), %rbx
	.p2align 4,,10
	.p2align 3
.L35:
	movl	$8, %edi
	addq	$8, %r14
	call	malloc@PLT
	movq	%rax, -8(%r14)
	movq	$0, (%rax)
	cmpq	%rbx, %r14
	jne	.L35
	movl	-72(%rbp), %eax
	testl	%eax, %eax
	jle	.L49
.L48:
	leaq	-60(%rbp), %rax
	xorl	%ebx, %ebx
	leaq	-64(%rbp), %r15
	movq	%rax, -112(%rbp)
	leaq	-68(%rbp), %r14
	jmp	.L42
	.p2align 4,,10
	.p2align 3
.L37:
	cmpl	$1, %eax
	je	.L68
	cmpl	$2, %eax
	je	.L69
.L40:
	addl	$1, %ebx
	cmpl	%ebx, -72(%rbp)
	jle	.L70
.L42:
	movq	%r15, %rdx
	movq	%r14, %rsi
	movq	%r13, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	-68(%rbp), %eax
	testl	%eax, %eax
	jne	.L37
	movq	-112(%rbp), %rsi
	leaq	.LC2(%rip), %rdi
	call	__isoc99_scanf@PLT
	movslq	-64(%rbp), %rax
	movl	-60(%rbp), %esi
	movq	(%r12,%rax,8), %rdx
	movq	(%rdx), %rcx
	testq	%rcx, %rcx
	je	.L71
	movl	$16, %edi
	movq	%rcx, -104(%rbp)
	addl	$1, %ebx
	movq	%rdx, -96(%rbp)
	movl	%esi, -84(%rbp)
	call	malloc@PLT
	movq	-104(%rbp), %rcx
	movl	-84(%rbp), %esi
	movq	-96(%rbp), %rdx
	movq	%rcx, 8(%rax)
	movl	%esi, (%rax)
	movq	%rax, (%rdx)
	cmpl	%ebx, -72(%rbp)
	jg	.L42
.L70:
	movl	-76(%rbp), %edx
	testl	%edx, %edx
	jle	.L43
.L49:
	xorl	%r13d, %r13d
	.p2align 4,,10
	.p2align 3
.L47:
	movq	(%r12,%r13,8), %r14
	movq	(%r14), %rdi
	testq	%rdi, %rdi
	je	.L44
	movq	8(%rdi), %rbx
	testq	%rbx, %rbx
	je	.L46
	.p2align 4,,10
	.p2align 3
.L45:
	call	free@PLT
	movq	%rbx, %rdi
	movq	8(%rbx), %rbx
	testq	%rbx, %rbx
	jne	.L45
.L46:
	call	free@PLT
	movq	%r14, %rdi
	call	free@PLT
.L44:
	addq	$1, %r13
	cmpl	%r13d, -76(%rbp)
	jg	.L47
.L43:
	movq	-56(%rbp), %rax
	subq	%fs:40, %rax
	jne	.L72
	leaq	-40(%rbp), %rsp
	xorl	%eax, %eax
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	.cfi_remember_state
	.cfi_def_cfa 7, 8
	ret
	.p2align 4,,10
	.p2align 3
.L68:
	.cfi_restore_state
	movslq	-64(%rbp), %rax
	movq	(%r12,%rax,8), %rax
	movq	(%rax), %rax
	testq	%rax, %rax
	je	.L40
	movl	(%rax), %edx
	leaq	.LC0(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L40
	.p2align 4,,10
	.p2align 3
.L71:
	movl	$16, %edi
	movq	%rdx, -96(%rbp)
	movl	%esi, -84(%rbp)
	call	malloc@PLT
	movq	-96(%rbp), %rdx
	movl	-84(%rbp), %esi
	movq	$0, 8(%rax)
	movq	%rax, (%rdx)
	movl	%esi, (%rax)
	jmp	.L40
	.p2align 4,,10
	.p2align 3
.L69:
	movslq	-64(%rbp), %rax
	movq	(%r12,%rax,8), %rdi
	call	pop
	jmp	.L40
.L34:
	cmpl	$0, -72(%rbp)
	jg	.L48
	jmp	.L43
.L72:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE44:
	.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	CreateStack
	.type	CreateStack, @function
CreateStack:
.LFB39:
	.cfi_startproc
	endbr64
	subq	$8, %rsp
	.cfi_def_cfa_offset 16
	movl	$8, %edi
	call	malloc@PLT
	movq	$0, (%rax)
	addq	$8, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE39:
	.size	CreateStack, .-CreateStack
	.p2align 4
	.globl	push
	.type	push, @function
push:
.LFB40:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	movl	%esi, %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	movq	(%rdi), %r12
	movq	%rdi, %rbx
	movl	$16, %edi
	testq	%r12, %r12
	je	.L8
	call	malloc@PLT
	movq	%r12, 8(%rax)
	movl	%ebp, (%rax)
	movq	%rax, (%rbx)
	popq	%rbx
	.cfi_remember_state
	.cfi_def_cfa_offset 24
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L8:
	.cfi_restore_state
	call	malloc@PLT
	movl	%ebp, (%rax)
	movq	$0, 8(%rax)
	movq	%rax, (%rbx)
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE40:
	.size	push, .-push
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d\n"
	.text
	.p2align 4
	.globl	top
	.type	top, @function
top:
.LFB41:
	.cfi_startproc
	endbr64
	movq	(%rdi), %rax
	testq	%rax, %rax
	je	.L9
	movl	(%rax), %edx
	leaq	.LC0(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	jmp	__printf_chk@PLT
	.p2align 4,,10
	.p2align 3
.L9:
	ret
	.cfi_endproc
.LFE41:
	.size	top, .-top
	.p2align 4
	.globl	pop
	.type	pop, @function
pop:
.LFB42:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	pushq	%rbx
	.cfi_def_cfa_offset 24
	.cfi_offset 3, -24
	movq	%rdi, %rbx
	subq	$8, %rsp
	.cfi_def_cfa_offset 32
	movq	(%rdi), %rdi
	testq	%rdi, %rdi
	je	.L11
	movq	8(%rdi), %rbp
	testq	%rbp, %rbp
	je	.L18
	call	free@PLT
	movq	%rbp, (%rbx)
.L11:
	addq	$8, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 24
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L18:
	.cfi_restore_state
	call	free@PLT
	movq	$0, (%rbx)
	addq	$8, %rsp
	.cfi_def_cfa_offset 24
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE42:
	.size	pop, .-pop
	.p2align 4
	.globl	deleteStack
	.type	deleteStack, @function
deleteStack:
.LFB43:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	movq	%rdi, %r12
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	subq	$8, %rsp
	.cfi_def_cfa_offset 32
	movq	(%rdi), %rdi
	testq	%rdi, %rdi
	je	.L19
	movq	8(%rdi), %rbp
	testq	%rbp, %rbp
	jne	.L21
	jmp	.L28
	.p2align 4,,10
	.p2align 3
.L29:
	movq	%rax, %rbp
.L21:
	call	free@PLT
	movq	8(%rbp), %rax
	movq	%rbp, %rdi
	testq	%rax, %rax
	jne	.L29
.L22:
	movq	%rbp, %rdi
	call	free@PLT
	addq	$8, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 24
	movq	%r12, %rdi
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	jmp	free@PLT
	.p2align 4,,10
	.p2align 3
.L19:
	.cfi_restore_state
	addq	$8, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 24
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L28:
	.cfi_restore_state
	movq	%rdi, %rbp
	jmp	.L22
	.cfi_endproc
.LFE43:
	.size	deleteStack, .-deleteStack
	.section	.rodata.str1.1
.LC1:
	.string	"%d %d"
.LC2:
	.string	"%d"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB44:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	pushq	%r15
	pushq	%r14
	leaq	-72(%rbp), %rdx
	leaq	-76(%rbp), %rsi
	pushq	%r13
	.cfi_offset 15, -24
	.cfi_offset 14, -32
	.cfi_offset 13, -40
	leaq	.LC1(%rip), %r13
	pushq	%r12
	movq	%r13, %rdi
	pushq	%rbx
	subq	$72, %rsp
	.cfi_offset 12, -48
	.cfi_offset 3, -56
	movq	%fs:40, %rax
	movq	%rax, -56(%rbp)
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	leaq	-4096(%rsp), %rax
	cmpq	%rax, %rsp
	je	.L32
.L67:
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	cmpq	%rax, %rsp
	jne	.L67
.L32:
	subq	$3904, %rsp
	orq	$0, 3896(%rsp)
	movl	-76(%rbp), %eax
	movq	%rsp, %r12
	testl	%eax, %eax
	jle	.L34
	movq	%r12, %r14
	leaq	(%r12,%rax,8), %rbx
	.p2align 4,,10
	.p2align 3
.L35:
	movl	$8, %edi
	addq	$8, %r14
	call	malloc@PLT
	movq	%rax, -8(%r14)
	movq	$0, (%rax)
	cmpq	%rbx, %r14
	jne	.L35
	movl	-72(%rbp), %eax
	testl	%eax, %eax
	jle	.L49
.L48:
	leaq	-60(%rbp), %rax
	xorl	%ebx, %ebx
	leaq	-64(%rbp), %r15
	movq	%rax, -112(%rbp)
	leaq	-68(%rbp), %r14
	jmp	.L42
	.p2align 4,,10
	.p2align 3
.L37:
	cmpl	$1, %eax
	je	.L68
	cmpl	$2, %eax
	je	.L69
.L40:
	addl	$1, %ebx
	cmpl	%ebx, -72(%rbp)
	jle	.L70
.L42:
	movq	%r15, %rdx
	movq	%r14, %rsi
	movq	%r13, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	-68(%rbp), %eax
	testl	%eax, %eax
	jne	.L37
	movq	-112(%rbp), %rsi
	leaq	.LC2(%rip), %rdi
	call	__isoc99_scanf@PLT
	movslq	-64(%rbp), %rax
	movl	-60(%rbp), %esi
	movq	(%r12,%rax,8), %rdx
	movq	(%rdx), %rcx
	testq	%rcx, %rcx
	je	.L71
	movl	$16, %edi
	movq	%rcx, -104(%rbp)
	addl	$1, %ebx
	movq	%rdx, -96(%rbp)
	movl	%esi, -84(%rbp)
	call	malloc@PLT
	movq	-104(%rbp), %rcx
	movl	-84(%rbp), %esi
	movq	-96(%rbp), %rdx
	movq	%rcx, 8(%rax)
	movl	%esi, (%rax)
	movq	%rax, (%rdx)
	cmpl	%ebx, -72(%rbp)
	jg	.L42
.L70:
	movl	-76(%rbp), %edx
	testl	%edx, %edx
	jle	.L43
.L49:
	xorl	%r13d, %r13d
	.p2align 4,,10
	.p2align 3
.L47:
	movq	(%r12,%r13,8), %r14
	movq	(%r14), %rdi
	testq	%rdi, %rdi
	je	.L44
	movq	8(%rdi), %rbx
	testq	%rbx, %rbx
	je	.L46
	.p2align 4,,10
	.p2align 3
.L45:
	call	free@PLT
	movq	%rbx, %rdi
	movq	8(%rbx), %rbx
	testq	%rbx, %rbx
	jne	.L45
.L46:
	call	free@PLT
	movq	%r14, %rdi
	call	free@PLT
.L44:
	addq	$1, %r13
	cmpl	%r13d, -76(%rbp)
	jg	.L47
.L43:
	movq	-56(%rbp), %rax
	subq	%fs:40, %rax
	jne	.L72
	leaq	-40(%rbp), %rsp
	xorl	%eax, %eax
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	.cfi_remember_state
	.cfi_def_cfa 7, 8
	ret
	.p2align 4,,10
	.p2align 3
.L68:
	.cfi_restore_state
	movslq	-64(%rbp), %rax
	movq	(%r12,%rax,8), %rax
	movq	(%rax), %rax
	testq	%rax, %rax
	je	.L40
	movl	(%rax), %edx
	leaq	.LC0(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L40
	.p2align 4,,10
	.p2align 3
.L71:
	movl	$16, %edi
	movq	%rdx, -96(%rbp)
	movl	%esi, -84(%rbp)
	call	malloc@PLT
	movq	-96(%rbp), %rdx
	movl	-84(%rbp), %esi
	movq	$0, 8(%rax)
	movq	%rax, (%rdx)
	movl	%esi, (%rax)
	jmp	.L40
	.p2align 4,,10
	.p2align 3
.L69:
	movslq	-64(%rbp), %rax
	movq	(%r12,%rax,8), %rdi
	call	pop
	jmp	.L40
.L34:
	cmpl	$0, -72(%rbp)
	jg	.L48
	jmp	.L43
.L72:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE44:
	.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:

/*
 * FileName:     stack_model
 * CreatedDate:  2020-05-23 23:19:48 +0900
 * LastModified: 2020-05-23 23:31:24 +0900
 */

#include<stdio.h>
#include<stdlib.h>
static const int MAX_N = 1000;

typedef struct Node{
    int data;
    struct Node *under;
}node_str;
typedef struct Stack{
    node_str *top;
}stack_str;

stack_str *CreateStack(){
    stack_str *S = malloc(sizeof(stack_str));
    S->top = NULL;
    return S;
}
void push(stack_str *S, int x){
    if(S->top == NULL){
	S->top = malloc(sizeof(node_str));
	S->top->data = x;
	S->top->under = NULL;
    }else{
	node_str *bf = malloc(sizeof(node_str));
	bf->under = S->top;
	bf->data = x;
	S->top = bf;
    }
}
void top(stack_str *S){
    if(S->top == NULL) return;
    printf("%d\n", S->top->data);
}
void pop(stack_str *S){
    if(S->top == NULL) return;
    if(S->top->under == NULL){
	free(S->top);
	S->top = NULL;
	return;
    }
    node_str *bf = S->top->under;
    free(S->top);
    S->top = bf;
}
void deleteStack(stack_str *S){
    if(S->top == NULL) return;
    node_str *cur = S->top;
    for(;;){
	if(cur->under == NULL){
	    free(cur);
	    break;
        }
	node_str *bf = cur->under;
	free(cur);
	cur = bf;
    }
    free(S);
}

int main(){
    int n, q;
    scanf("%d %d", &n, &q);
    stack_str *S[MAX_N];
    for(int i = 0; i < n; i++) S[i] = CreateStack();
    for(int i = 0; i < q; i++){
	int op, t;
	scanf("%d %d", &op, &t);
	if(op == 0){
	    int x;
	    scanf("%d", &x);
	    push(S[t], x);
	}else if(op == 1){
	    top(S[t]);
	}else if(op == 2){
	    pop(S[t]);
	}
    }
    for(int i = 0; i < n; i++) deleteStack(S[i]);
    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
/*
 * FileName:     stack_model
 * CreatedDate:  2020-05-23 23:19:48 +0900
 * LastModified: 2020-05-23 23:31:24 +0900
 */

#include<stdio.h>
#include<stdlib.h>
static const int MAX_N = 1000;

typedef struct Node{
    int data;
    struct Node *under;
}node_str;
typedef struct Stack{
    node_str *top;
}stack_str;

stack_str *CreateStack(){
    stack_str *S = malloc(sizeof(stack_str));
    S->top = NULL;
    return S;
}
void push(stack_str *S, int x){
    if(S->top == NULL){
	S->top = malloc(sizeof(node_str));
	S->top->data = x;
	S->top->under = NULL;
    }else{
	node_str *bf = malloc(sizeof(node_str));
	bf->under = S->top;
	bf->data = x;
	S->top = bf;
    }
}
void top(stack_str *S){
    if(S->top == NULL) return;
    printf("%d\n", S->top->data);
}
void pop(stack_str *S){
    if(S->top == NULL) return;
    if(S->top->under == NULL){
	free(S->top);
	S->top = NULL;
	return;
    }
    node_str *bf = S->top->under;
    free(S->top);
    S->top = bf;
}
void deleteStack(stack_str *S){
    if(S->top == NULL) return;
    node_str *cur = S->top;
    for(;;){
	if(cur->under == NULL){
	    free(cur);
	    break;
        }
	node_str *bf = cur->under;
	free(cur);
	cur = bf;
    }
    free(S);
}

int main(){
    int n, q;
    scanf("%d %d", &n, &q);
    stack_str *S[MAX_N];
    for(int i = 0; i < n; i++) S[i] = CreateStack();
    for(int i = 0; i < q; i++){
	int op, t;
	scanf("%d %d", &op, &t);
	if(op == 0){
	    int x;
	    scanf("%d", &x);
	    push(S[t], x);
	}else if(op == 1){
	    top(S[t]);
	}else if(op == 2){
	    pop(S[t]);
	}
    }
    for(int i = 0; i < n; i++) deleteStack(S[i]);
    return 0;
}

```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
	.align 4
	.type	MAX_N, @object
	.size	MAX_N, 4
MAX_N:
	.long	1000
	.text
	.globl	CreateStack
	.type	CreateStack, @function
CreateStack:
.LFB6:
	.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
	movl	$8, %edi
	call	malloc@PLT
	movq	%rax, -8(%rbp)
	movq	-8(%rbp), %rax
	movq	$0, (%rax)
	movq	-8(%rbp), %rax
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	CreateStack, .-CreateStack
	.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	$32, %rsp
	movq	%rdi, -24(%rbp)
	movl	%esi, -28(%rbp)
	movq	-24(%rbp), %rax
	movq	(%rax), %rax
	testq	%rax, %rax
	jne	.L4
	movl	$16, %edi
	call	malloc@PLT
	movq	%rax, %rdx
	movq	-24(%rbp), %rax
	movq	%rdx, (%rax)
	movq	-24(%rbp), %rax
	movq	(%rax), %rax
	movl	-28(%rbp), %edx
	movl	%edx, (%rax)
	movq	-24(%rbp), %rax
	movq	(%rax), %rax
	movq	$0, 8(%rax)
	jmp	.L6
.L4:
	movl	$16, %edi
	call	malloc@PLT
	movq	%rax, -8(%rbp)
	movq	-24(%rbp), %rax
	movq	(%rax), %rdx
	movq	-8(%rbp), %rax
	movq	%rdx, 8(%rax)
	movq	-8(%rbp), %rax
	movl	-28(%rbp), %edx
	movl	%edx, (%rax)
	movq	-24(%rbp), %rax
	movq	-8(%rbp), %rdx
	movq	%rdx, (%rax)
.L6:
	nop
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.size	push, .-push
	.section	.rodata
.LC0:
	.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	-8(%rbp), %rax
	movq	(%rax), %rax
	testq	%rax, %rax
	je	.L10
	movq	-8(%rbp), %rax
	movq	(%rax), %rax
	movl	(%rax), %eax
	movl	%eax, %esi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L7
.L10:
	nop
.L7:
	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
	subq	$32, %rsp
	movq	%rdi, -24(%rbp)
	movq	-24(%rbp), %rax
	movq	(%rax), %rax
	testq	%rax, %rax
	je	.L15
	movq	-24(%rbp), %rax
	movq	(%rax), %rax
	movq	8(%rax), %rax
	testq	%rax, %rax
	jne	.L14
	movq	-24(%rbp), %rax
	movq	(%rax), %rax
	movq	%rax, %rdi
	call	free@PLT
	movq	-24(%rbp), %rax
	movq	$0, (%rax)
	jmp	.L11
.L14:
	movq	-24(%rbp), %rax
	movq	(%rax), %rax
	movq	8(%rax), %rax
	movq	%rax, -8(%rbp)
	movq	-24(%rbp), %rax
	movq	(%rax), %rax
	movq	%rax, %rdi
	call	free@PLT
	movq	-24(%rbp), %rax
	movq	-8(%rbp), %rdx
	movq	%rdx, (%rax)
	jmp	.L11
.L15:
	nop
.L11:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE9:
	.size	pop, .-pop
	.globl	deleteStack
	.type	deleteStack, @function
deleteStack:
.LFB10:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$32, %rsp
	movq	%rdi, -24(%rbp)
	movq	-24(%rbp), %rax
	movq	(%rax), %rax
	testq	%rax, %rax
	je	.L22
	movq	-24(%rbp), %rax
	movq	(%rax), %rax
	movq	%rax, -16(%rbp)
.L21:
	movq	-16(%rbp), %rax
	movq	8(%rax), %rax
	testq	%rax, %rax
	jne	.L19
	movq	-16(%rbp), %rax
	movq	%rax, %rdi
	call	free@PLT
	nop
	movq	-24(%rbp), %rax
	movq	%rax, %rdi
	call	free@PLT
	jmp	.L16
.L19:
	movq	-16(%rbp), %rax
	movq	8(%rax), %rax
	movq	%rax, -8(%rbp)
	movq	-16(%rbp), %rax
	movq	%rax, %rdi
	call	free@PLT
	movq	-8(%rbp), %rax
	movq	%rax, -16(%rbp)
	jmp	.L21
.L22:
	nop
.L16:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE10:
	.size	deleteStack, .-deleteStack
	.section	.rodata
.LC1:
	.string	"%d %d"
.LC2:
	.string	"%d"
	.text
	.globl	main
	.type	main, @function
main:
.LFB11:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	pushq	%r15
	pushq	%r14
	pushq	%r13
	pushq	%r12
	pushq	%rbx
	subq	$72, %rsp
	.cfi_offset 15, -24
	.cfi_offset 14, -32
	.cfi_offset 13, -40
	.cfi_offset 12, -48
	.cfi_offset 3, -56
	movq	%fs:40, %rax
	movq	%rax, -56(%rbp)
	xorl	%eax, %eax
	movq	%rsp, %rax
	movq	%rax, %rbx
	leaq	-100(%rbp), %rdx
	leaq	-104(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$1000, %eax
	cltq
	subq	$1, %rax
	movq	%rax, -72(%rbp)
	movl	$1000, %eax
	cltq
	movq	%rax, %r14
	movl	$0, %r15d
	movl	$1000, %eax
	cltq
	movq	%rax, %r12
	movl	$0, %r13d
	movl	$1000, %eax
	cltq
	leaq	0(,%rax,8), %rdx
	movl	$16, %eax
	subq	$1, %rax
	addq	%rdx, %rax
	movl	$16, %esi
	movl	$0, %edx
	divq	%rsi
	imulq	$16, %rax, %rax
	movq	%rax, %rcx
	andq	$-4096, %rcx
	movq	%rsp, %rdx
	subq	%rcx, %rdx
.L24:
	cmpq	%rdx, %rsp
	je	.L25
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	jmp	.L24
.L25:
	movq	%rax, %rdx
	andl	$4095, %edx
	subq	%rdx, %rsp
	movq	%rax, %rdx
	andl	$4095, %edx
	testq	%rdx, %rdx
	je	.L26
	andl	$4095, %eax
	subq	$8, %rax
	addq	%rsp, %rax
	orq	$0, (%rax)
.L26:
	movq	%rsp, %rax
	addq	$7, %rax
	shrq	$3, %rax
	salq	$3, %rax
	movq	%rax, -64(%rbp)
	movl	$0, -84(%rbp)
	jmp	.L27
.L28:
	movl	$0, %eax
	call	CreateStack
	movq	-64(%rbp), %rdx
	movl	-84(%rbp), %ecx
	movslq	%ecx, %rcx
	movq	%rax, (%rdx,%rcx,8)
	addl	$1, -84(%rbp)
.L27:
	movl	-104(%rbp), %eax
	cmpl	%eax, -84(%rbp)
	jl	.L28
	movl	$0, -80(%rbp)
	jmp	.L29
.L33:
	leaq	-92(%rbp), %rdx
	leaq	-96(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-96(%rbp), %eax
	testl	%eax, %eax
	jne	.L30
	leaq	-88(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-88(%rbp), %edx
	movl	-92(%rbp), %ecx
	movq	-64(%rbp), %rax
	movslq	%ecx, %rcx
	movq	(%rax,%rcx,8), %rax
	movl	%edx, %esi
	movq	%rax, %rdi
	call	push
	jmp	.L31
.L30:
	movl	-96(%rbp), %eax
	cmpl	$1, %eax
	jne	.L32
	movl	-92(%rbp), %edx
	movq	-64(%rbp), %rax
	movslq	%edx, %rdx
	movq	(%rax,%rdx,8), %rax
	movq	%rax, %rdi
	call	top
	jmp	.L31
.L32:
	movl	-96(%rbp), %eax
	cmpl	$2, %eax
	jne	.L31
	movl	-92(%rbp), %edx
	movq	-64(%rbp), %rax
	movslq	%edx, %rdx
	movq	(%rax,%rdx,8), %rax
	movq	%rax, %rdi
	call	pop
.L31:
	addl	$1, -80(%rbp)
.L29:
	movl	-100(%rbp), %eax
	cmpl	%eax, -80(%rbp)
	jl	.L33
	movl	$0, -76(%rbp)
	jmp	.L34
.L35:
	movq	-64(%rbp), %rax
	movl	-76(%rbp), %edx
	movslq	%edx, %rdx
	movq	(%rax,%rdx,8), %rax
	movq	%rax, %rdi
	call	deleteStack
	addl	$1, -76(%rbp)
.L34:
	movl	-104(%rbp), %eax
	cmpl	%eax, -76(%rbp)
	jl	.L35
	movl	$0, %eax
	movq	%rbx, %rsp
	movq	-56(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L37
	call	__stack_chk_fail@PLT
.L37:
	leaq	-40(%rbp), %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE11:
	.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
	.align 4
	.type	MAX_N, @object
	.size	MAX_N, 4
MAX_N:
	.long	1000
	.text
	.globl	CreateStack
	.type	CreateStack, @function
CreateStack:
.LFB6:
	.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
	movl	$8, %edi
	call	malloc@PLT
	movq	%rax, -8(%rbp)
	movq	-8(%rbp), %rax
	movq	$0, (%rax)
	movq	-8(%rbp), %rax
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	CreateStack, .-CreateStack
	.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	$32, %rsp
	movq	%rdi, -24(%rbp)
	movl	%esi, -28(%rbp)
	movq	-24(%rbp), %rax
	movq	(%rax), %rax
	testq	%rax, %rax
	jne	.L4
	movl	$16, %edi
	call	malloc@PLT
	movq	%rax, %rdx
	movq	-24(%rbp), %rax
	movq	%rdx, (%rax)
	movq	-24(%rbp), %rax
	movq	(%rax), %rax
	movl	-28(%rbp), %edx
	movl	%edx, (%rax)
	movq	-24(%rbp), %rax
	movq	(%rax), %rax
	movq	$0, 8(%rax)
	jmp	.L6
.L4:
	movl	$16, %edi
	call	malloc@PLT
	movq	%rax, -8(%rbp)
	movq	-24(%rbp), %rax
	movq	(%rax), %rdx
	movq	-8(%rbp), %rax
	movq	%rdx, 8(%rax)
	movq	-8(%rbp), %rax
	movl	-28(%rbp), %edx
	movl	%edx, (%rax)
	movq	-24(%rbp), %rax
	movq	-8(%rbp), %rdx
	movq	%rdx, (%rax)
.L6:
	nop
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.size	push, .-push
	.section	.rodata
.LC0:
	.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	-8(%rbp), %rax
	movq	(%rax), %rax
	testq	%rax, %rax
	je	.L10
	movq	-8(%rbp), %rax
	movq	(%rax), %rax
	movl	(%rax), %eax
	movl	%eax, %esi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L7
.L10:
	nop
.L7:
	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
	subq	$32, %rsp
	movq	%rdi, -24(%rbp)
	movq	-24(%rbp), %rax
	movq	(%rax), %rax
	testq	%rax, %rax
	je	.L15
	movq	-24(%rbp), %rax
	movq	(%rax), %rax
	movq	8(%rax), %rax
	testq	%rax, %rax
	jne	.L14
	movq	-24(%rbp), %rax
	movq	(%rax), %rax
	movq	%rax, %rdi
	call	free@PLT
	movq	-24(%rbp), %rax
	movq	$0, (%rax)
	jmp	.L11
.L14:
	movq	-24(%rbp), %rax
	movq	(%rax), %rax
	movq	8(%rax), %rax
	movq	%rax, -8(%rbp)
	movq	-24(%rbp), %rax
	movq	(%rax), %rax
	movq	%rax, %rdi
	call	free@PLT
	movq	-24(%rbp), %rax
	movq	-8(%rbp), %rdx
	movq	%rdx, (%rax)
	jmp	.L11
.L15:
	nop
.L11:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE9:
	.size	pop, .-pop
	.globl	deleteStack
	.type	deleteStack, @function
deleteStack:
.LFB10:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$32, %rsp
	movq	%rdi, -24(%rbp)
	movq	-24(%rbp), %rax
	movq	(%rax), %rax
	testq	%rax, %rax
	je	.L22
	movq	-24(%rbp), %rax
	movq	(%rax), %rax
	movq	%rax, -16(%rbp)
.L21:
	movq	-16(%rbp), %rax
	movq	8(%rax), %rax
	testq	%rax, %rax
	jne	.L19
	movq	-16(%rbp), %rax
	movq	%rax, %rdi
	call	free@PLT
	nop
	movq	-24(%rbp), %rax
	movq	%rax, %rdi
	call	free@PLT
	jmp	.L16
.L19:
	movq	-16(%rbp), %rax
	movq	8(%rax), %rax
	movq	%rax, -8(%rbp)
	movq	-16(%rbp), %rax
	movq	%rax, %rdi
	call	free@PLT
	movq	-8(%rbp), %rax
	movq	%rax, -16(%rbp)
	jmp	.L21
.L22:
	nop
.L16:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE10:
	.size	deleteStack, .-deleteStack
	.section	.rodata
.LC1:
	.string	"%d %d"
.LC2:
	.string	"%d"
	.text
	.globl	main
	.type	main, @function
main:
.LFB11:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	pushq	%r15
	pushq	%r14
	pushq	%r13
	pushq	%r12
	pushq	%rbx
	subq	$72, %rsp
	.cfi_offset 15, -24
	.cfi_offset 14, -32
	.cfi_offset 13, -40
	.cfi_offset 12, -48
	.cfi_offset 3, -56
	movq	%fs:40, %rax
	movq	%rax, -56(%rbp)
	xorl	%eax, %eax
	movq	%rsp, %rax
	movq	%rax, %rbx
	leaq	-100(%rbp), %rdx
	leaq	-104(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$1000, %eax
	cltq
	subq	$1, %rax
	movq	%rax, -72(%rbp)
	movl	$1000, %eax
	cltq
	movq	%rax, %r14
	movl	$0, %r15d
	movl	$1000, %eax
	cltq
	movq	%rax, %r12
	movl	$0, %r13d
	movl	$1000, %eax
	cltq
	leaq	0(,%rax,8), %rdx
	movl	$16, %eax
	subq	$1, %rax
	addq	%rdx, %rax
	movl	$16, %esi
	movl	$0, %edx
	divq	%rsi
	imulq	$16, %rax, %rax
	movq	%rax, %rcx
	andq	$-4096, %rcx
	movq	%rsp, %rdx
	subq	%rcx, %rdx
.L24:
	cmpq	%rdx, %rsp
	je	.L25
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	jmp	.L24
.L25:
	movq	%rax, %rdx
	andl	$4095, %edx
	subq	%rdx, %rsp
	movq	%rax, %rdx
	andl	$4095, %edx
	testq	%rdx, %rdx
	je	.L26
	andl	$4095, %eax
	subq	$8, %rax
	addq	%rsp, %rax
	orq	$0, (%rax)
.L26:
	movq	%rsp, %rax
	addq	$7, %rax
	shrq	$3, %rax
	salq	$3, %rax
	movq	%rax, -64(%rbp)
	movl	$0, -84(%rbp)
	jmp	.L27
.L28:
	movl	$0, %eax
	call	CreateStack
	movq	-64(%rbp), %rdx
	movl	-84(%rbp), %ecx
	movslq	%ecx, %rcx
	movq	%rax, (%rdx,%rcx,8)
	addl	$1, -84(%rbp)
.L27:
	movl	-104(%rbp), %eax
	cmpl	%eax, -84(%rbp)
	jl	.L28
	movl	$0, -80(%rbp)
	jmp	.L29
.L33:
	leaq	-92(%rbp), %rdx
	leaq	-96(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-96(%rbp), %eax
	testl	%eax, %eax
	jne	.L30
	leaq	-88(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-88(%rbp), %edx
	movl	-92(%rbp), %ecx
	movq	-64(%rbp), %rax
	movslq	%ecx, %rcx
	movq	(%rax,%rcx,8), %rax
	movl	%edx, %esi
	movq	%rax, %rdi
	call	push
	jmp	.L31
.L30:
	movl	-96(%rbp), %eax
	cmpl	$1, %eax
	jne	.L32
	movl	-92(%rbp), %edx
	movq	-64(%rbp), %rax
	movslq	%edx, %rdx
	movq	(%rax,%rdx,8), %rax
	movq	%rax, %rdi
	call	top
	jmp	.L31
.L32:
	movl	-96(%rbp), %eax
	cmpl	$2, %eax
	jne	.L31
	movl	-92(%rbp), %edx
	movq	-64(%rbp), %rax
	movslq	%edx, %rdx
	movq	(%rax,%rdx,8), %rax
	movq	%rax, %rdi
	call	pop
.L31:
	addl	$1, -80(%rbp)
.L29:
	movl	-100(%rbp), %eax
	cmpl	%eax, -80(%rbp)
	jl	.L33
	movl	$0, -76(%rbp)
	jmp	.L34
.L35:
	movq	-64(%rbp), %rax
	movl	-76(%rbp), %edx
	movslq	%edx, %rdx
	movq	(%rax,%rdx,8), %rax
	movq	%rax, %rdi
	call	deleteStack
	addl	$1, -76(%rbp)
.L34:
	movl	-104(%rbp), %eax
	cmpl	%eax, -76(%rbp)
	jl	.L35
	movl	$0, %eax
	movq	%rbx, %rsp
	movq	-56(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L37
	call	__stack_chk_fail@PLT
.L37:
	leaq	-40(%rbp), %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE11:
	.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:
