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>
#include <string.h>
#define MAX 1000

int top;
int S[MAX];

int initialize(){
       return top=0;
       }

int isempty(){
       return top==0;
       }

int isfull(){
       return top>=MAX-1;
       }

void push(int n){
       if (isfull()){return;}

       top++;
       S[top]=n;
       }

int pop(){
       if (isempty()){return;}

       top--;
       return S[top+1];
       }

int main(){
       int i,j,x,y;
       char op[MAX];
       initialize();
       while(scanf("%s",&op) != EOF){
                   if(op[0]=='+'){
                               x=pop();
                               y=pop();
                               push(y+x);
                               }
                   else if(op[0]=='-'){
                               x=pop();
                               y=pop();
                               push(y-x);
                               }
                   else if(op[0]=='*'){
                               x=pop();
                               y=pop();
                               push(y*x);
                               }
                   else {push(atoi(op));}
                   }
          printf("%d\n",pop());
          return 0;
          }


```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	top
	.bss
	.align 4
	.type	top, @object
	.size	top, 4
top:
	.zero	4
	.globl	S
	.align 32
	.type	S, @object
	.size	S, 4000
S:
	.zero	4000
	.text
	.globl	initialize
	.type	initialize, @function
initialize:
.LFB6:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	$0, top(%rip)
	movl	top(%rip), %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	initialize, .-initialize
	.globl	isempty
	.type	isempty, @function
isempty:
.LFB7:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	top(%rip), %eax
	testl	%eax, %eax
	sete	%al
	movzbl	%al, %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.size	isempty, .-isempty
	.globl	isfull
	.type	isfull, @function
isfull:
.LFB8:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	top(%rip), %eax
	cmpl	$998, %eax
	setg	%al
	movzbl	%al, %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE8:
	.size	isfull, .-isfull
	.globl	push
	.type	push, @function
push:
.LFB9:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$8, %rsp
	movl	%edi, -4(%rbp)
	movl	$0, %eax
	call	isfull
	testl	%eax, %eax
	jne	.L10
	movl	top(%rip), %eax
	addl	$1, %eax
	movl	%eax, top(%rip)
	movl	top(%rip), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	S(%rip), %rdx
	movl	-4(%rbp), %eax
	movl	%eax, (%rcx,%rdx)
	jmp	.L7
.L10:
	nop
.L7:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE9:
	.size	push, .-push
	.globl	pop
	.type	pop, @function
pop:
.LFB10:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	$0, %eax
	call	isempty
	testl	%eax, %eax
	jne	.L16
	movl	top(%rip), %eax
	subl	$1, %eax
	movl	%eax, top(%rip)
	movl	top(%rip), %eax
	addl	$1, %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	S(%rip), %rax
	movl	(%rdx,%rax), %eax
	jmp	.L11
.L16:
	nop
	nop
.L11:
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE10:
	.size	pop, .-pop
	.section	.rodata
.LC0:
	.string	"%s"
.LC1:
	.string	"%d\n"
	.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
	subq	$1024, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	$0, %eax
	call	initialize
	jmp	.L18
.L22:
	movzbl	-1008(%rbp), %eax
	cmpb	$43, %al
	jne	.L19
	movl	$0, %eax
	call	pop
	movl	%eax, -1016(%rbp)
	movl	$0, %eax
	call	pop
	movl	%eax, -1012(%rbp)
	movl	-1012(%rbp), %edx
	movl	-1016(%rbp), %eax
	addl	%edx, %eax
	movl	%eax, %edi
	call	push
	jmp	.L18
.L19:
	movzbl	-1008(%rbp), %eax
	cmpb	$45, %al
	jne	.L20
	movl	$0, %eax
	call	pop
	movl	%eax, -1016(%rbp)
	movl	$0, %eax
	call	pop
	movl	%eax, -1012(%rbp)
	movl	-1012(%rbp), %eax
	subl	-1016(%rbp), %eax
	movl	%eax, %edi
	call	push
	jmp	.L18
.L20:
	movzbl	-1008(%rbp), %eax
	cmpb	$42, %al
	jne	.L21
	movl	$0, %eax
	call	pop
	movl	%eax, -1016(%rbp)
	movl	$0, %eax
	call	pop
	movl	%eax, -1012(%rbp)
	movl	-1012(%rbp), %eax
	imull	-1016(%rbp), %eax
	movl	%eax, %edi
	call	push
	jmp	.L18
.L21:
	leaq	-1008(%rbp), %rax
	movq	%rax, %rdi
	call	atoi@PLT
	movl	%eax, %edi
	call	push
.L18:
	leaq	-1008(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	cmpl	$-1, %eax
	jne	.L22
	movl	$0, %eax
	call	pop
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L24
	call	__stack_chk_fail@PLT
.L24:
	leave
	.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	initialize
	.type	initialize, @function
initialize:
.LFB51:
	.cfi_startproc
	endbr64
	movl	$0, top(%rip)
	xorl	%eax, %eax
	ret
	.cfi_endproc
.LFE51:
	.size	initialize, .-initialize
	.p2align 4
	.globl	isempty
	.type	isempty, @function
isempty:
.LFB52:
	.cfi_startproc
	endbr64
	movl	top(%rip), %edx
	xorl	%eax, %eax
	testl	%edx, %edx
	sete	%al
	ret
	.cfi_endproc
.LFE52:
	.size	isempty, .-isempty
	.p2align 4
	.globl	isfull
	.type	isfull, @function
isfull:
.LFB53:
	.cfi_startproc
	endbr64
	xorl	%eax, %eax
	cmpl	$998, top(%rip)
	setg	%al
	ret
	.cfi_endproc
.LFE53:
	.size	isfull, .-isfull
	.p2align 4
	.globl	push
	.type	push, @function
push:
.LFB54:
	.cfi_startproc
	endbr64
	movl	top(%rip), %eax
	cmpl	$998, %eax
	jg	.L5
	addl	$1, %eax
	leaq	S(%rip), %rdx
	movl	%eax, top(%rip)
	cltq
	movl	%edi, (%rdx,%rax,4)
.L5:
	ret
	.cfi_endproc
.LFE54:
	.size	push, .-push
	.p2align 4
	.globl	pop
	.type	pop, @function
pop:
.LFB55:
	.cfi_startproc
	endbr64
	movslq	top(%rip), %rax
	testl	%eax, %eax
	je	.L9
	leal	-1(%rax), %edx
	movl	%edx, top(%rip)
	leaq	S(%rip), %rdx
	movl	(%rdx,%rax,4), %eax
	ret
	.p2align 4,,10
	.p2align 3
.L9:
	ret
	.cfi_endproc
.LFE55:
	.size	pop, .-pop
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%s"
.LC1:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB56:
	.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
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	leaq	S(%rip), %rbx
	subq	$1032, %rsp
	.cfi_def_cfa_offset 1088
	movq	%fs:40, %rax
	movq	%rax, 1016(%rsp)
	xorl	%eax, %eax
	leaq	16(%rsp), %rbp
	movl	$0, top(%rip)
	.p2align 4,,10
	.p2align 3
.L11:
	xorl	%eax, %eax
	movq	%rbp, %rsi
	movq	%r12, %rdi
	call	__isoc99_scanf@PLT
	cmpl	$-1, %eax
	je	.L45
	movzbl	16(%rsp), %eax
	cmpb	$43, %al
	je	.L46
	cmpb	$45, %al
	je	.L47
	cmpb	$42, %al
	jne	.L17
	movl	top(%rip), %eax
	testl	%eax, %eax
	je	.L18
	movslq	%eax, %rdx
	movl	(%rbx,%rdx,4), %edi
	movl	%eax, %edx
	movl	%edi, (%rsp)
	subl	$1, %edx
	je	.L48
	movslq	%edx, %rdx
	subl	$2, %eax
	movl	(%rbx,%rdx,4), %ecx
	movl	%eax, top(%rip)
	movl	%ecx, 8(%rsp)
	cmpl	$998, %eax
	jg	.L11
	imull	(%rsp), %ecx
	movl	%ecx, %edx
	.p2align 4,,10
	.p2align 3
.L23:
	addl	$1, %eax
	movl	%eax, top(%rip)
	cltq
	movl	%edx, (%rbx,%rax,4)
	jmp	.L11
	.p2align 4,,10
	.p2align 3
.L46:
	movl	top(%rip), %eax
	testl	%eax, %eax
	je	.L13
	movslq	%eax, %rdx
	movl	(%rbx,%rdx,4), %r14d
	movl	%eax, %edx
	subl	$1, %edx
	je	.L13
	movslq	%edx, %rdx
	subl	$2, %eax
	movl	(%rbx,%rdx,4), %r13d
	movl	%eax, top(%rip)
	leal	0(%r13,%r14), %edx
	cmpl	$998, %eax
	jg	.L11
	jmp	.L23
	.p2align 4,,10
	.p2align 3
.L47:
	movl	top(%rip), %eax
	testl	%eax, %eax
	je	.L16
	movslq	%eax, %rdx
	movl	(%rbx,%rdx,4), %r15d
	movl	%eax, %edx
	subl	$1, %edx
	je	.L49
	movslq	%edx, %rdx
	subl	$2, %eax
	movl	(%rbx,%rdx,4), %ecx
	movl	%eax, top(%rip)
	movl	%ecx, 4(%rsp)
	cmpl	$998, %eax
	jg	.L11
	subl	%r15d, %ecx
	movl	%ecx, %edx
	jmp	.L23
	.p2align 4,,10
	.p2align 3
.L17:
	movl	$10, %edx
	xorl	%esi, %esi
	movq	%rbp, %rdi
	call	strtol@PLT
	movl	top(%rip), %edx
	cmpl	$998, %edx
	jg	.L11
	addl	$1, %edx
	movl	%edx, top(%rip)
	movslq	%edx, %rdx
	movl	%eax, (%rbx,%rdx,4)
	jmp	.L11
	.p2align 4,,10
	.p2align 3
.L45:
	movslq	top(%rip), %rax
	testl	%eax, %eax
	je	.L20
	leal	-1(%rax), %edx
	movl	%edx, top(%rip)
	leaq	S(%rip), %rdx
	movl	(%rdx,%rax,4), %eax
	movl	%eax, 12(%rsp)
.L20:
	movl	12(%rsp), %edx
	xorl	%eax, %eax
	movl	$1, %edi
	leaq	.LC1(%rip), %rsi
	call	__printf_chk@PLT
	movq	1016(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L50
	addq	$1032, %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
	leal	0(%r13,%r14), %edx
	xorl	%eax, %eax
	jmp	.L23
.L49:
	xorl	%eax, %eax
.L16:
	movl	4(%rsp), %edx
	subl	%r15d, %edx
	jmp	.L23
.L48:
	xorl	%eax, %eax
.L18:
	movl	8(%rsp), %edx
	imull	(%rsp), %edx
	jmp	.L23
.L50:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE56:
	.size	main, .-main
	.globl	S
	.bss
	.align 32
	.type	S, @object
	.size	S, 4000
S:
	.zero	4000
	.globl	top
	.align 4
	.type	top, @object
	.size	top, 4
top:
	.zero	4
	.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	initialize
	.type	initialize, @function
initialize:
.LFB51:
	.cfi_startproc
	endbr64
	movl	$0, top(%rip)
	xorl	%eax, %eax
	ret
	.cfi_endproc
.LFE51:
	.size	initialize, .-initialize
	.p2align 4
	.globl	isempty
	.type	isempty, @function
isempty:
.LFB52:
	.cfi_startproc
	endbr64
	movl	top(%rip), %edx
	xorl	%eax, %eax
	testl	%edx, %edx
	sete	%al
	ret
	.cfi_endproc
.LFE52:
	.size	isempty, .-isempty
	.p2align 4
	.globl	isfull
	.type	isfull, @function
isfull:
.LFB53:
	.cfi_startproc
	endbr64
	xorl	%eax, %eax
	cmpl	$998, top(%rip)
	setg	%al
	ret
	.cfi_endproc
.LFE53:
	.size	isfull, .-isfull
	.p2align 4
	.globl	push
	.type	push, @function
push:
.LFB54:
	.cfi_startproc
	endbr64
	movl	top(%rip), %eax
	cmpl	$998, %eax
	jg	.L5
	addl	$1, %eax
	leaq	S(%rip), %rdx
	movl	%eax, top(%rip)
	cltq
	movl	%edi, (%rdx,%rax,4)
.L5:
	ret
	.cfi_endproc
.LFE54:
	.size	push, .-push
	.p2align 4
	.globl	pop
	.type	pop, @function
pop:
.LFB55:
	.cfi_startproc
	endbr64
	movslq	top(%rip), %rax
	testl	%eax, %eax
	je	.L9
	leal	-1(%rax), %edx
	movl	%edx, top(%rip)
	leaq	S(%rip), %rdx
	movl	(%rdx,%rax,4), %eax
	ret
	.p2align 4,,10
	.p2align 3
.L9:
	ret
	.cfi_endproc
.LFE55:
	.size	pop, .-pop
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%s"
.LC1:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB56:
	.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
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	leaq	S(%rip), %rbx
	subq	$1032, %rsp
	.cfi_def_cfa_offset 1088
	movq	%fs:40, %rax
	movq	%rax, 1016(%rsp)
	xorl	%eax, %eax
	leaq	16(%rsp), %rbp
	movl	$0, top(%rip)
	.p2align 4,,10
	.p2align 3
.L11:
	xorl	%eax, %eax
	movq	%rbp, %rsi
	movq	%r12, %rdi
	call	__isoc99_scanf@PLT
	cmpl	$-1, %eax
	je	.L45
	movzbl	16(%rsp), %eax
	cmpb	$43, %al
	je	.L46
	cmpb	$45, %al
	je	.L47
	cmpb	$42, %al
	jne	.L17
	movl	top(%rip), %eax
	testl	%eax, %eax
	je	.L18
	movslq	%eax, %rdx
	movl	(%rbx,%rdx,4), %edi
	movl	%eax, %edx
	movl	%edi, (%rsp)
	subl	$1, %edx
	je	.L48
	movslq	%edx, %rdx
	subl	$2, %eax
	movl	(%rbx,%rdx,4), %ecx
	movl	%eax, top(%rip)
	movl	%ecx, 8(%rsp)
	cmpl	$998, %eax
	jg	.L11
	imull	(%rsp), %ecx
	movl	%ecx, %edx
	.p2align 4,,10
	.p2align 3
.L23:
	addl	$1, %eax
	movl	%eax, top(%rip)
	cltq
	movl	%edx, (%rbx,%rax,4)
	jmp	.L11
	.p2align 4,,10
	.p2align 3
.L46:
	movl	top(%rip), %eax
	testl	%eax, %eax
	je	.L13
	movslq	%eax, %rdx
	movl	(%rbx,%rdx,4), %r14d
	movl	%eax, %edx
	subl	$1, %edx
	je	.L13
	movslq	%edx, %rdx
	subl	$2, %eax
	movl	(%rbx,%rdx,4), %r13d
	movl	%eax, top(%rip)
	leal	0(%r13,%r14), %edx
	cmpl	$998, %eax
	jg	.L11
	jmp	.L23
	.p2align 4,,10
	.p2align 3
.L47:
	movl	top(%rip), %eax
	testl	%eax, %eax
	je	.L16
	movslq	%eax, %rdx
	movl	(%rbx,%rdx,4), %r15d
	movl	%eax, %edx
	subl	$1, %edx
	je	.L49
	movslq	%edx, %rdx
	subl	$2, %eax
	movl	(%rbx,%rdx,4), %ecx
	movl	%eax, top(%rip)
	movl	%ecx, 4(%rsp)
	cmpl	$998, %eax
	jg	.L11
	subl	%r15d, %ecx
	movl	%ecx, %edx
	jmp	.L23
	.p2align 4,,10
	.p2align 3
.L17:
	movl	$10, %edx
	xorl	%esi, %esi
	movq	%rbp, %rdi
	call	strtol@PLT
	movl	top(%rip), %edx
	cmpl	$998, %edx
	jg	.L11
	addl	$1, %edx
	movl	%edx, top(%rip)
	movslq	%edx, %rdx
	movl	%eax, (%rbx,%rdx,4)
	jmp	.L11
	.p2align 4,,10
	.p2align 3
.L45:
	movslq	top(%rip), %rax
	testl	%eax, %eax
	je	.L20
	leal	-1(%rax), %edx
	movl	%edx, top(%rip)
	leaq	S(%rip), %rdx
	movl	(%rdx,%rax,4), %eax
	movl	%eax, 12(%rsp)
.L20:
	movl	12(%rsp), %edx
	xorl	%eax, %eax
	movl	$1, %edi
	leaq	.LC1(%rip), %rsi
	call	__printf_chk@PLT
	movq	1016(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L50
	addq	$1032, %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
	leal	0(%r13,%r14), %edx
	xorl	%eax, %eax
	jmp	.L23
.L49:
	xorl	%eax, %eax
.L16:
	movl	4(%rsp), %edx
	subl	%r15d, %edx
	jmp	.L23
.L48:
	xorl	%eax, %eax
.L18:
	movl	8(%rsp), %edx
	imull	(%rsp), %edx
	jmp	.L23
.L50:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE56:
	.size	main, .-main
	.globl	S
	.bss
	.align 32
	.type	S, @object
	.size	S, 4000
S:
	.zero	4000
	.globl	top
	.align 4
	.type	top, @object
	.size	top, 4
top:
	.zero	4
	.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>
#include <string.h>
#define MAX 1000

int top;
int S[MAX];

int initialize(){
       return top=0;
       }

int isempty(){
       return top==0;
       }

int isfull(){
       return top>=MAX-1;
       }

void push(int n){
       if (isfull()){return;}

       top++;
       S[top]=n;
       }

int pop(){
       if (isempty()){return;}

       top--;
       return S[top+1];
       }

int main(){
       int i,j,x,y;
       char op[MAX];
       initialize();
       while(scanf("%s",&op) != EOF){
                   if(op[0]=='+'){
                               x=pop();
                               y=pop();
                               push(y+x);
                               }
                   else if(op[0]=='-'){
                               x=pop();
                               y=pop();
                               push(y-x);
                               }
                   else if(op[0]=='*'){
                               x=pop();
                               y=pop();
                               push(y*x);
                               }
                   else {push(atoi(op));}
                   }
          printf("%d\n",pop());
          return 0;
          }



1 4 + 3 4 - *
 1 3 +
 1 4 + 2 4 - *
 0 3 +
 1 1 + 2 4 - *
 0 3 *
 1 4 + 3 8 - *
 0 5 +
 1 1 + 3 4 - *
 1 4 * 3 1 - *

-5
 4
 -10
 3
 -4
 0
 -25
 5
 -2
 8

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>
#include <string.h>
#define MAX 1000

int top;
int S[MAX];

int initialize(){
       return top=0;
       }

int isempty(){
       return top==0;
       }

int isfull(){
       return top>=MAX-1;
       }

void push(int n){
       if (isfull()){return;}

       top++;
       S[top]=n;
       }

int pop(){
       if (isempty()){return;}

       top--;
       return S[top+1];
       }

int main(){
       int i,j,x,y;
       char op[MAX];
       initialize();
       while(scanf("%s",&op) != EOF){
                   if(op[0]=='+'){
                               x=pop();
                               y=pop();
                               push(y+x);
                               }
                   else if(op[0]=='-'){
                               x=pop();
                               y=pop();
                               push(y-x);
                               }
                   else if(op[0]=='*'){
                               x=pop();
                               y=pop();
                               push(y*x);
                               }
                   else {push(atoi(op));}
                   }
          printf("%d\n",pop());
          return 0;
          }


```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	top
	.bss
	.align 4
	.type	top, @object
	.size	top, 4
top:
	.zero	4
	.globl	S
	.align 32
	.type	S, @object
	.size	S, 4000
S:
	.zero	4000
	.text
	.globl	initialize
	.type	initialize, @function
initialize:
.LFB6:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	$0, top(%rip)
	movl	top(%rip), %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	initialize, .-initialize
	.globl	isempty
	.type	isempty, @function
isempty:
.LFB7:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	top(%rip), %eax
	testl	%eax, %eax
	sete	%al
	movzbl	%al, %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.size	isempty, .-isempty
	.globl	isfull
	.type	isfull, @function
isfull:
.LFB8:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	top(%rip), %eax
	cmpl	$998, %eax
	setg	%al
	movzbl	%al, %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE8:
	.size	isfull, .-isfull
	.globl	push
	.type	push, @function
push:
.LFB9:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$8, %rsp
	movl	%edi, -4(%rbp)
	movl	$0, %eax
	call	isfull
	testl	%eax, %eax
	jne	.L10
	movl	top(%rip), %eax
	addl	$1, %eax
	movl	%eax, top(%rip)
	movl	top(%rip), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	S(%rip), %rdx
	movl	-4(%rbp), %eax
	movl	%eax, (%rcx,%rdx)
	jmp	.L7
.L10:
	nop
.L7:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE9:
	.size	push, .-push
	.globl	pop
	.type	pop, @function
pop:
.LFB10:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	$0, %eax
	call	isempty
	testl	%eax, %eax
	jne	.L16
	movl	top(%rip), %eax
	subl	$1, %eax
	movl	%eax, top(%rip)
	movl	top(%rip), %eax
	addl	$1, %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	S(%rip), %rax
	movl	(%rdx,%rax), %eax
	jmp	.L11
.L16:
	nop
	nop
.L11:
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE10:
	.size	pop, .-pop
	.section	.rodata
.LC0:
	.string	"%s"
.LC1:
	.string	"%d\n"
	.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
	subq	$1024, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	$0, %eax
	call	initialize
	jmp	.L18
.L22:
	movzbl	-1008(%rbp), %eax
	cmpb	$43, %al
	jne	.L19
	movl	$0, %eax
	call	pop
	movl	%eax, -1016(%rbp)
	movl	$0, %eax
	call	pop
	movl	%eax, -1012(%rbp)
	movl	-1012(%rbp), %edx
	movl	-1016(%rbp), %eax
	addl	%edx, %eax
	movl	%eax, %edi
	call	push
	jmp	.L18
.L19:
	movzbl	-1008(%rbp), %eax
	cmpb	$45, %al
	jne	.L20
	movl	$0, %eax
	call	pop
	movl	%eax, -1016(%rbp)
	movl	$0, %eax
	call	pop
	movl	%eax, -1012(%rbp)
	movl	-1012(%rbp), %eax
	subl	-1016(%rbp), %eax
	movl	%eax, %edi
	call	push
	jmp	.L18
.L20:
	movzbl	-1008(%rbp), %eax
	cmpb	$42, %al
	jne	.L21
	movl	$0, %eax
	call	pop
	movl	%eax, -1016(%rbp)
	movl	$0, %eax
	call	pop
	movl	%eax, -1012(%rbp)
	movl	-1012(%rbp), %eax
	imull	-1016(%rbp), %eax
	movl	%eax, %edi
	call	push
	jmp	.L18
.L21:
	leaq	-1008(%rbp), %rax
	movq	%rax, %rdi
	call	atoi@PLT
	movl	%eax, %edi
	call	push
.L18:
	leaq	-1008(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	cmpl	$-1, %eax
	jne	.L22
	movl	$0, %eax
	call	pop
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L24
	call	__stack_chk_fail@PLT
.L24:
	leave
	.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
	.globl	top
	.bss
	.align 4
	.type	top, @object
	.size	top, 4
top:
	.zero	4
	.globl	S
	.align 32
	.type	S, @object
	.size	S, 4000
S:
	.zero	4000
	.text
	.globl	initialize
	.type	initialize, @function
initialize:
.LFB6:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	$0, top(%rip)
	movl	top(%rip), %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	initialize, .-initialize
	.globl	isempty
	.type	isempty, @function
isempty:
.LFB7:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	top(%rip), %eax
	testl	%eax, %eax
	sete	%al
	movzbl	%al, %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.size	isempty, .-isempty
	.globl	isfull
	.type	isfull, @function
isfull:
.LFB8:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	top(%rip), %eax
	cmpl	$998, %eax
	setg	%al
	movzbl	%al, %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE8:
	.size	isfull, .-isfull
	.globl	push
	.type	push, @function
push:
.LFB9:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$8, %rsp
	movl	%edi, -4(%rbp)
	movl	$0, %eax
	call	isfull
	testl	%eax, %eax
	jne	.L10
	movl	top(%rip), %eax
	addl	$1, %eax
	movl	%eax, top(%rip)
	movl	top(%rip), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	S(%rip), %rdx
	movl	-4(%rbp), %eax
	movl	%eax, (%rcx,%rdx)
	jmp	.L7
.L10:
	nop
.L7:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE9:
	.size	push, .-push
	.globl	pop
	.type	pop, @function
pop:
.LFB10:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	$0, %eax
	call	isempty
	testl	%eax, %eax
	jne	.L16
	movl	top(%rip), %eax
	subl	$1, %eax
	movl	%eax, top(%rip)
	movl	top(%rip), %eax
	addl	$1, %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	S(%rip), %rax
	movl	(%rdx,%rax), %eax
	jmp	.L11
.L16:
	nop
	nop
.L11:
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE10:
	.size	pop, .-pop
	.section	.rodata
.LC0:
	.string	"%s"
.LC1:
	.string	"%d\n"
	.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
	subq	$1024, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	$0, %eax
	call	initialize
	jmp	.L18
.L22:
	movzbl	-1008(%rbp), %eax
	cmpb	$43, %al
	jne	.L19
	movl	$0, %eax
	call	pop
	movl	%eax, -1016(%rbp)
	movl	$0, %eax
	call	pop
	movl	%eax, -1012(%rbp)
	movl	-1012(%rbp), %edx
	movl	-1016(%rbp), %eax
	addl	%edx, %eax
	movl	%eax, %edi
	call	push
	jmp	.L18
.L19:
	movzbl	-1008(%rbp), %eax
	cmpb	$45, %al
	jne	.L20
	movl	$0, %eax
	call	pop
	movl	%eax, -1016(%rbp)
	movl	$0, %eax
	call	pop
	movl	%eax, -1012(%rbp)
	movl	-1012(%rbp), %eax
	subl	-1016(%rbp), %eax
	movl	%eax, %edi
	call	push
	jmp	.L18
.L20:
	movzbl	-1008(%rbp), %eax
	cmpb	$42, %al
	jne	.L21
	movl	$0, %eax
	call	pop
	movl	%eax, -1016(%rbp)
	movl	$0, %eax
	call	pop
	movl	%eax, -1012(%rbp)
	movl	-1012(%rbp), %eax
	imull	-1016(%rbp), %eax
	movl	%eax, %edi
	call	push
	jmp	.L18
.L21:
	leaq	-1008(%rbp), %rax
	movq	%rax, %rdi
	call	atoi@PLT
	movl	%eax, %edi
	call	push
.L18:
	leaq	-1008(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	cmpl	$-1, %eax
	jne	.L22
	movl	$0, %eax
	call	pop
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L24
	call	__stack_chk_fail@PLT
.L24:
	leave
	.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:
