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>
#define N 100


 int n,pos,count=0;
 int pre[N],in[N],post[N];
 
 int find(int in[n],int root){
     int i;
     for(i=0;i<n;i++){
            if(in[i]==root)return i;
            }
     return in[n-1];
     }

 void rec(int l,int r){
      int root,m;
      if(l>=r)return;
      root=pre[pos++];
      m=find(in,root);
      rec(l,m);
      rec(m+1,r);
      post[count++]=root;
      }

 void solve(){
      int i;
      pos=0;
      rec(0,n);
      for(i=0;i<n;i++){
              if(i)printf(" ");
              printf("%d",post[i]);
              }
      printf("\n");
      }

 int main(){
      int i,k;
      scanf("%d",&n);

      for(i=0;i<n;i++){
              scanf("%d",&k);
              pre[i]=k;
              }
      for(i=0;i<n;i++){
              scanf("%d",&k);
              in[i]=k;
              }
      solve();
      return 0;
      }

```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	n
	.bss
	.align 4
	.type	n, @object
	.size	n, 4
n:
	.zero	4
	.globl	pos
	.align 4
	.type	pos, @object
	.size	pos, 4
pos:
	.zero	4
	.globl	count
	.align 4
	.type	count, @object
	.size	count, 4
count:
	.zero	4
	.globl	pre
	.align 32
	.type	pre, @object
	.size	pre, 400
pre:
	.zero	400
	.globl	in
	.align 32
	.type	in, @object
	.size	in, 400
in:
	.zero	400
	.globl	post
	.align 32
	.type	post, @object
	.size	post, 400
post:
	.zero	400
	.text
	.globl	find
	.type	find, @function
find:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movq	%rdi, -24(%rbp)
	movl	%esi, -28(%rbp)
	movl	$0, -4(%rbp)
	jmp	.L2
.L5:
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	cmpl	%eax, -28(%rbp)
	jne	.L3
	movl	-4(%rbp), %eax
	jmp	.L4
.L3:
	addl	$1, -4(%rbp)
.L2:
	movl	n(%rip), %eax
	cmpl	%eax, -4(%rbp)
	jl	.L5
	movl	n(%rip), %eax
	cltq
	salq	$2, %rax
	leaq	-4(%rax), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
.L4:
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	find, .-find
	.globl	rec
	.type	rec, @function
rec:
.LFB1:
	.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
	movl	%edi, -20(%rbp)
	movl	%esi, -24(%rbp)
	movl	-20(%rbp), %eax
	cmpl	-24(%rbp), %eax
	jge	.L9
	movl	pos(%rip), %eax
	leal	1(%rax), %edx
	movl	%edx, pos(%rip)
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	pre(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -8(%rbp)
	movl	-8(%rbp), %eax
	movl	%eax, %esi
	leaq	in(%rip), %rax
	movq	%rax, %rdi
	call	find
	movl	%eax, -4(%rbp)
	movl	-4(%rbp), %edx
	movl	-20(%rbp), %eax
	movl	%edx, %esi
	movl	%eax, %edi
	call	rec
	movl	-4(%rbp), %eax
	leal	1(%rax), %edx
	movl	-24(%rbp), %eax
	movl	%eax, %esi
	movl	%edx, %edi
	call	rec
	movl	count(%rip), %eax
	leal	1(%rax), %edx
	movl	%edx, count(%rip)
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	post(%rip), %rdx
	movl	-8(%rbp), %eax
	movl	%eax, (%rcx,%rdx)
	jmp	.L6
.L9:
	nop
.L6:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.size	rec, .-rec
	.section	.rodata
.LC0:
	.string	"%d"
	.text
	.globl	solve
	.type	solve, @function
solve:
.LFB2:
	.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	$0, pos(%rip)
	movl	n(%rip), %eax
	movl	%eax, %esi
	movl	$0, %edi
	call	rec
	movl	$0, -4(%rbp)
	jmp	.L11
.L13:
	cmpl	$0, -4(%rbp)
	je	.L12
	movl	$32, %edi
	call	putchar@PLT
.L12:
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	post(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, %esi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	addl	$1, -4(%rbp)
.L11:
	movl	n(%rip), %eax
	cmpl	%eax, -4(%rbp)
	jl	.L13
	movl	$10, %edi
	call	putchar@PLT
	nop
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE2:
	.size	solve, .-solve
	.globl	main
	.type	main, @function
main:
.LFB3:
	.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	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	n(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -12(%rbp)
	jmp	.L15
.L16:
	leaq	-16(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-16(%rbp), %eax
	movl	-12(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	pre(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	addl	$1, -12(%rbp)
.L15:
	movl	n(%rip), %eax
	cmpl	%eax, -12(%rbp)
	jl	.L16
	movl	$0, -12(%rbp)
	jmp	.L17
.L18:
	leaq	-16(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-16(%rbp), %eax
	movl	-12(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	in(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	addl	$1, -12(%rbp)
.L17:
	movl	n(%rip), %eax
	cmpl	%eax, -12(%rbp)
	jl	.L18
	movl	$0, %eax
	call	solve
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L20
	call	__stack_chk_fail@PLT
.L20:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE3:
	.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
	.type	rec.part.0, @function
rec.part.0:
.LFB27:
	.cfi_startproc
	movslq	pos(%rip), %rax
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	movl	%esi, %r12d
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	leal	1(%rax), %edx
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	movl	%edx, pos(%rip)
	leaq	pre(%rip), %rdx
	movl	(%rdx,%rax,4), %ebp
	movslq	n(%rip), %rdx
	testl	%edx, %edx
	jle	.L2
	xorl	%eax, %eax
	leaq	in(%rip), %rcx
	jmp	.L4
	.p2align 4,,10
	.p2align 3
.L12:
	addq	$1, %rax
	cmpq	%rax, %rdx
	je	.L2
.L4:
	movl	%eax, %ebx
	cmpl	(%rcx,%rax,4), %ebp
	jne	.L12
.L3:
	cmpl	%ebx, %edi
	jge	.L5
	movl	%ebx, %esi
	call	rec.part.0
.L5:
	leal	1(%rbx), %edi
	cmpl	%r12d, %edi
	jge	.L6
	movl	%r12d, %esi
	call	rec.part.0
.L6:
	movslq	count(%rip), %rax
	leal	1(%rax), %edx
	movl	%edx, count(%rip)
	leaq	post(%rip), %rdx
	movl	%ebp, (%rdx,%rax,4)
	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
.L2:
	.cfi_restore_state
	leaq	-4+in(%rip), %rax
	movl	(%rax,%rdx,4), %ebx
	jmp	.L3
	.cfi_endproc
.LFE27:
	.size	rec.part.0, .-rec.part.0
	.p2align 4
	.globl	find
	.type	find, @function
find:
.LFB23:
	.cfi_startproc
	endbr64
	movslq	n(%rip), %rdx
	testl	%edx, %edx
	jle	.L14
	xorl	%eax, %eax
	jmp	.L16
	.p2align 4,,10
	.p2align 3
.L20:
	addq	$1, %rax
	cmpq	%rdx, %rax
	je	.L14
.L16:
	movl	%eax, %r8d
	cmpl	%esi, (%rdi,%rax,4)
	jne	.L20
	movl	%r8d, %eax
	ret
	.p2align 4,,10
	.p2align 3
.L14:
	movl	-4(%rdi,%rdx,4), %r8d
	movl	%r8d, %eax
	ret
	.cfi_endproc
.LFE23:
	.size	find, .-find
	.p2align 4
	.globl	rec
	.type	rec, @function
rec:
.LFB24:
	.cfi_startproc
	endbr64
	cmpl	%esi, %edi
	jge	.L21
	jmp	rec.part.0
	.p2align 4,,10
	.p2align 3
.L21:
	ret
	.cfi_endproc
.LFE24:
	.size	rec, .-rec
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d"
	.text
	.p2align 4
	.globl	solve
	.type	solve, @function
solve:
.LFB25:
	.cfi_startproc
	endbr64
	movl	$0, pos(%rip)
	movl	n(%rip), %esi
	testl	%esi, %esi
	jle	.L32
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	xorl	%edi, %edi
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	call	rec.part.0
	movl	n(%rip), %eax
	testl	%eax, %eax
	jle	.L26
	xorl	%ebx, %ebx
	leaq	post(%rip), %r12
	leaq	.LC0(%rip), %rbp
	jmp	.L25
	.p2align 4,,10
	.p2align 3
.L27:
	movl	$32, %edi
	call	putchar@PLT
.L25:
	movl	(%r12,%rbx,4), %edx
	xorl	%eax, %eax
	movq	%rbp, %rsi
	movl	$1, %edi
	addq	$1, %rbx
	call	__printf_chk@PLT
	cmpl	%ebx, n(%rip)
	jg	.L27
.L26:
	popq	%rbx
	.cfi_restore 3
	.cfi_def_cfa_offset 24
	movl	$10, %edi
	popq	%rbp
	.cfi_restore 6
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_restore 12
	.cfi_def_cfa_offset 8
	jmp	putchar@PLT
	.p2align 4,,10
	.p2align 3
.L32:
	movl	$10, %edi
	jmp	putchar@PLT
	.cfi_endproc
.LFE25:
	.size	solve, .-solve
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB26:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	leaq	n(%rip), %rsi
	leaq	pre(%rip), %r13
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	leaq	.LC0(%rip), %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	movq	%rbp, %rdi
	xorl	%ebx, %ebx
	subq	$24, %rsp
	.cfi_def_cfa_offset 64
	movq	%fs:40, %rax
	movq	%rax, 8(%rsp)
	xorl	%eax, %eax
	leaq	4(%rsp), %r12
	call	__isoc99_scanf@PLT
	movl	n(%rip), %eax
	testl	%eax, %eax
	jle	.L35
	.p2align 4,,10
	.p2align 3
.L34:
	movq	%r12, %rsi
	movq	%rbp, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	4(%rsp), %eax
	movl	%eax, 0(%r13,%rbx,4)
	movl	n(%rip), %eax
	addq	$1, %rbx
	cmpl	%ebx, %eax
	jg	.L34
	testl	%eax, %eax
	jle	.L35
	xorl	%ebx, %ebx
	leaq	in(%rip), %r13
	.p2align 4,,10
	.p2align 3
.L36:
	xorl	%eax, %eax
	movq	%r12, %rsi
	movq	%rbp, %rdi
	call	__isoc99_scanf@PLT
	movl	4(%rsp), %eax
	movl	%eax, 0(%r13,%rbx,4)
	addq	$1, %rbx
	cmpl	%ebx, n(%rip)
	jg	.L36
.L35:
	xorl	%eax, %eax
	call	solve
	movq	8(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L45
	addq	$24, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 40
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%rbp
	.cfi_def_cfa_offset 24
	popq	%r12
	.cfi_def_cfa_offset 16
	popq	%r13
	.cfi_def_cfa_offset 8
	ret
.L45:
	.cfi_restore_state
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE26:
	.size	main, .-main
	.globl	post
	.bss
	.align 32
	.type	post, @object
	.size	post, 400
post:
	.zero	400
	.globl	in
	.align 32
	.type	in, @object
	.size	in, 400
in:
	.zero	400
	.globl	pre
	.align 32
	.type	pre, @object
	.size	pre, 400
pre:
	.zero	400
	.globl	count
	.align 4
	.type	count, @object
	.size	count, 4
count:
	.zero	4
	.globl	pos
	.align 4
	.type	pos, @object
	.size	pos, 4
pos:
	.zero	4
	.globl	n
	.align 4
	.type	n, @object
	.size	n, 4
n:
	.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
	.type	rec.part.0, @function
rec.part.0:
.LFB27:
	.cfi_startproc
	movslq	pos(%rip), %rax
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	movl	%esi, %r12d
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	leal	1(%rax), %edx
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	movl	%edx, pos(%rip)
	leaq	pre(%rip), %rdx
	movl	(%rdx,%rax,4), %ebp
	movslq	n(%rip), %rdx
	testl	%edx, %edx
	jle	.L2
	xorl	%eax, %eax
	leaq	in(%rip), %rcx
	jmp	.L4
	.p2align 4,,10
	.p2align 3
.L12:
	addq	$1, %rax
	cmpq	%rax, %rdx
	je	.L2
.L4:
	movl	%eax, %ebx
	cmpl	(%rcx,%rax,4), %ebp
	jne	.L12
.L3:
	cmpl	%ebx, %edi
	jge	.L5
	movl	%ebx, %esi
	call	rec.part.0
.L5:
	leal	1(%rbx), %edi
	cmpl	%r12d, %edi
	jge	.L6
	movl	%r12d, %esi
	call	rec.part.0
.L6:
	movslq	count(%rip), %rax
	leal	1(%rax), %edx
	movl	%edx, count(%rip)
	leaq	post(%rip), %rdx
	movl	%ebp, (%rdx,%rax,4)
	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
.L2:
	.cfi_restore_state
	leaq	-4+in(%rip), %rax
	movl	(%rax,%rdx,4), %ebx
	jmp	.L3
	.cfi_endproc
.LFE27:
	.size	rec.part.0, .-rec.part.0
	.p2align 4
	.globl	find
	.type	find, @function
find:
.LFB23:
	.cfi_startproc
	endbr64
	movslq	n(%rip), %rdx
	testl	%edx, %edx
	jle	.L14
	xorl	%eax, %eax
	jmp	.L16
	.p2align 4,,10
	.p2align 3
.L20:
	addq	$1, %rax
	cmpq	%rdx, %rax
	je	.L14
.L16:
	movl	%eax, %r8d
	cmpl	%esi, (%rdi,%rax,4)
	jne	.L20
	movl	%r8d, %eax
	ret
	.p2align 4,,10
	.p2align 3
.L14:
	movl	-4(%rdi,%rdx,4), %r8d
	movl	%r8d, %eax
	ret
	.cfi_endproc
.LFE23:
	.size	find, .-find
	.p2align 4
	.globl	rec
	.type	rec, @function
rec:
.LFB24:
	.cfi_startproc
	endbr64
	cmpl	%esi, %edi
	jge	.L21
	jmp	rec.part.0
	.p2align 4,,10
	.p2align 3
.L21:
	ret
	.cfi_endproc
.LFE24:
	.size	rec, .-rec
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d"
	.text
	.p2align 4
	.globl	solve
	.type	solve, @function
solve:
.LFB25:
	.cfi_startproc
	endbr64
	movl	$0, pos(%rip)
	movl	n(%rip), %esi
	testl	%esi, %esi
	jle	.L32
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	xorl	%edi, %edi
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	call	rec.part.0
	movl	n(%rip), %eax
	testl	%eax, %eax
	jle	.L26
	xorl	%ebx, %ebx
	leaq	post(%rip), %r12
	leaq	.LC0(%rip), %rbp
	jmp	.L25
	.p2align 4,,10
	.p2align 3
.L27:
	movl	$32, %edi
	call	putchar@PLT
.L25:
	movl	(%r12,%rbx,4), %edx
	xorl	%eax, %eax
	movq	%rbp, %rsi
	movl	$1, %edi
	addq	$1, %rbx
	call	__printf_chk@PLT
	cmpl	%ebx, n(%rip)
	jg	.L27
.L26:
	popq	%rbx
	.cfi_restore 3
	.cfi_def_cfa_offset 24
	movl	$10, %edi
	popq	%rbp
	.cfi_restore 6
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_restore 12
	.cfi_def_cfa_offset 8
	jmp	putchar@PLT
	.p2align 4,,10
	.p2align 3
.L32:
	movl	$10, %edi
	jmp	putchar@PLT
	.cfi_endproc
.LFE25:
	.size	solve, .-solve
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB26:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	leaq	n(%rip), %rsi
	leaq	pre(%rip), %r13
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	leaq	.LC0(%rip), %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	movq	%rbp, %rdi
	xorl	%ebx, %ebx
	subq	$24, %rsp
	.cfi_def_cfa_offset 64
	movq	%fs:40, %rax
	movq	%rax, 8(%rsp)
	xorl	%eax, %eax
	leaq	4(%rsp), %r12
	call	__isoc99_scanf@PLT
	movl	n(%rip), %eax
	testl	%eax, %eax
	jle	.L35
	.p2align 4,,10
	.p2align 3
.L34:
	movq	%r12, %rsi
	movq	%rbp, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	4(%rsp), %eax
	movl	%eax, 0(%r13,%rbx,4)
	movl	n(%rip), %eax
	addq	$1, %rbx
	cmpl	%ebx, %eax
	jg	.L34
	testl	%eax, %eax
	jle	.L35
	xorl	%ebx, %ebx
	leaq	in(%rip), %r13
	.p2align 4,,10
	.p2align 3
.L36:
	xorl	%eax, %eax
	movq	%r12, %rsi
	movq	%rbp, %rdi
	call	__isoc99_scanf@PLT
	movl	4(%rsp), %eax
	movl	%eax, 0(%r13,%rbx,4)
	addq	$1, %rbx
	cmpl	%ebx, n(%rip)
	jg	.L36
.L35:
	xorl	%eax, %eax
	call	solve
	movq	8(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L45
	addq	$24, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 40
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%rbp
	.cfi_def_cfa_offset 24
	popq	%r12
	.cfi_def_cfa_offset 16
	popq	%r13
	.cfi_def_cfa_offset 8
	ret
.L45:
	.cfi_restore_state
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE26:
	.size	main, .-main
	.globl	post
	.bss
	.align 32
	.type	post, @object
	.size	post, 400
post:
	.zero	400
	.globl	in
	.align 32
	.type	in, @object
	.size	in, 400
in:
	.zero	400
	.globl	pre
	.align 32
	.type	pre, @object
	.size	pre, 400
pre:
	.zero	400
	.globl	count
	.align 4
	.type	count, @object
	.size	count, 4
count:
	.zero	4
	.globl	pos
	.align 4
	.type	pos, @object
	.size	pos, 4
pos:
	.zero	4
	.globl	n
	.align 4
	.type	n, @object
	.size	n, 4
n:
	.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>
#define N 100


 int n,pos,count=0;
 int pre[N],in[N],post[N];
 
 int find(int in[n],int root){
     int i;
     for(i=0;i<n;i++){
            if(in[i]==root)return i;
            }
     return in[n-1];
     }

 void rec(int l,int r){
      int root,m;
      if(l>=r)return;
      root=pre[pos++];
      m=find(in,root);
      rec(l,m);
      rec(m+1,r);
      post[count++]=root;
      }

 void solve(){
      int i;
      pos=0;
      rec(0,n);
      for(i=0;i<n;i++){
              if(i)printf(" ");
              printf("%d",post[i]);
              }
      printf("\n");
      }

 int main(){
      int i,k;
      scanf("%d",&n);

      for(i=0;i<n;i++){
              scanf("%d",&k);
              pre[i]=k;
              }
      for(i=0;i<n;i++){
              scanf("%d",&k);
              in[i]=k;
              }
      solve();
      return 0;
      }


4
1 2 3 4
2 1 3 4
 4
2 1 3 4
2 1 3 4
 4
2 1 3 4
3 1 2 4
 5
1 2 3 4 5
1 2 4 3 5
 4
2 1 3 4
1 2 3 4
 5
1 3 2 4 5
3 2 4 1 5
 4
1 4 3 2
1 2 3 4
 5
1 2 3 4 5
3 4 2 1 5
 4
1 2 3 4
1 2 4 3
 4
2 1 3 4
2 1 4 3

2 4 3 1
 4 3 1 2
 3 1 4 2
 4 5 3 2 1
 1 4 3 2
 4 2 3 5 1
 2 3 4 1
 4 3 2 5 1
 4 3 2 1
 4 3 1 2

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>
#define N 100


 int n,pos,count=0;
 int pre[N],in[N],post[N];
 
 int find(int in[n],int root){
     int i;
     for(i=0;i<n;i++){
            if(in[i]==root)return i;
            }
     return in[n-1];
     }

 void rec(int l,int r){
      int root,m;
      if(l>=r)return;
      root=pre[pos++];
      m=find(in,root);
      rec(l,m);
      rec(m+1,r);
      post[count++]=root;
      }

 void solve(){
      int i;
      pos=0;
      rec(0,n);
      for(i=0;i<n;i++){
              if(i)printf(" ");
              printf("%d",post[i]);
              }
      printf("\n");
      }

 int main(){
      int i,k;
      scanf("%d",&n);

      for(i=0;i<n;i++){
              scanf("%d",&k);
              pre[i]=k;
              }
      for(i=0;i<n;i++){
              scanf("%d",&k);
              in[i]=k;
              }
      solve();
      return 0;
      }

```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	n
	.bss
	.align 4
	.type	n, @object
	.size	n, 4
n:
	.zero	4
	.globl	pos
	.align 4
	.type	pos, @object
	.size	pos, 4
pos:
	.zero	4
	.globl	count
	.align 4
	.type	count, @object
	.size	count, 4
count:
	.zero	4
	.globl	pre
	.align 32
	.type	pre, @object
	.size	pre, 400
pre:
	.zero	400
	.globl	in
	.align 32
	.type	in, @object
	.size	in, 400
in:
	.zero	400
	.globl	post
	.align 32
	.type	post, @object
	.size	post, 400
post:
	.zero	400
	.text
	.globl	find
	.type	find, @function
find:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movq	%rdi, -24(%rbp)
	movl	%esi, -28(%rbp)
	movl	$0, -4(%rbp)
	jmp	.L2
.L5:
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	cmpl	%eax, -28(%rbp)
	jne	.L3
	movl	-4(%rbp), %eax
	jmp	.L4
.L3:
	addl	$1, -4(%rbp)
.L2:
	movl	n(%rip), %eax
	cmpl	%eax, -4(%rbp)
	jl	.L5
	movl	n(%rip), %eax
	cltq
	salq	$2, %rax
	leaq	-4(%rax), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
.L4:
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	find, .-find
	.globl	rec
	.type	rec, @function
rec:
.LFB1:
	.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
	movl	%edi, -20(%rbp)
	movl	%esi, -24(%rbp)
	movl	-20(%rbp), %eax
	cmpl	-24(%rbp), %eax
	jge	.L9
	movl	pos(%rip), %eax
	leal	1(%rax), %edx
	movl	%edx, pos(%rip)
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	pre(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -8(%rbp)
	movl	-8(%rbp), %eax
	movl	%eax, %esi
	leaq	in(%rip), %rax
	movq	%rax, %rdi
	call	find
	movl	%eax, -4(%rbp)
	movl	-4(%rbp), %edx
	movl	-20(%rbp), %eax
	movl	%edx, %esi
	movl	%eax, %edi
	call	rec
	movl	-4(%rbp), %eax
	leal	1(%rax), %edx
	movl	-24(%rbp), %eax
	movl	%eax, %esi
	movl	%edx, %edi
	call	rec
	movl	count(%rip), %eax
	leal	1(%rax), %edx
	movl	%edx, count(%rip)
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	post(%rip), %rdx
	movl	-8(%rbp), %eax
	movl	%eax, (%rcx,%rdx)
	jmp	.L6
.L9:
	nop
.L6:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.size	rec, .-rec
	.section	.rodata
.LC0:
	.string	"%d"
	.text
	.globl	solve
	.type	solve, @function
solve:
.LFB2:
	.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	$0, pos(%rip)
	movl	n(%rip), %eax
	movl	%eax, %esi
	movl	$0, %edi
	call	rec
	movl	$0, -4(%rbp)
	jmp	.L11
.L13:
	cmpl	$0, -4(%rbp)
	je	.L12
	movl	$32, %edi
	call	putchar@PLT
.L12:
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	post(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, %esi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	addl	$1, -4(%rbp)
.L11:
	movl	n(%rip), %eax
	cmpl	%eax, -4(%rbp)
	jl	.L13
	movl	$10, %edi
	call	putchar@PLT
	nop
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE2:
	.size	solve, .-solve
	.globl	main
	.type	main, @function
main:
.LFB3:
	.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	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	n(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -12(%rbp)
	jmp	.L15
.L16:
	leaq	-16(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-16(%rbp), %eax
	movl	-12(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	pre(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	addl	$1, -12(%rbp)
.L15:
	movl	n(%rip), %eax
	cmpl	%eax, -12(%rbp)
	jl	.L16
	movl	$0, -12(%rbp)
	jmp	.L17
.L18:
	leaq	-16(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-16(%rbp), %eax
	movl	-12(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	in(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	addl	$1, -12(%rbp)
.L17:
	movl	n(%rip), %eax
	cmpl	%eax, -12(%rbp)
	jl	.L18
	movl	$0, %eax
	call	solve
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L20
	call	__stack_chk_fail@PLT
.L20:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE3:
	.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	n
	.bss
	.align 4
	.type	n, @object
	.size	n, 4
n:
	.zero	4
	.globl	pos
	.align 4
	.type	pos, @object
	.size	pos, 4
pos:
	.zero	4
	.globl	count
	.align 4
	.type	count, @object
	.size	count, 4
count:
	.zero	4
	.globl	pre
	.align 32
	.type	pre, @object
	.size	pre, 400
pre:
	.zero	400
	.globl	in
	.align 32
	.type	in, @object
	.size	in, 400
in:
	.zero	400
	.globl	post
	.align 32
	.type	post, @object
	.size	post, 400
post:
	.zero	400
	.text
	.globl	find
	.type	find, @function
find:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movq	%rdi, -24(%rbp)
	movl	%esi, -28(%rbp)
	movl	$0, -4(%rbp)
	jmp	.L2
.L5:
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	cmpl	%eax, -28(%rbp)
	jne	.L3
	movl	-4(%rbp), %eax
	jmp	.L4
.L3:
	addl	$1, -4(%rbp)
.L2:
	movl	n(%rip), %eax
	cmpl	%eax, -4(%rbp)
	jl	.L5
	movl	n(%rip), %eax
	cltq
	salq	$2, %rax
	leaq	-4(%rax), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
.L4:
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	find, .-find
	.globl	rec
	.type	rec, @function
rec:
.LFB1:
	.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
	movl	%edi, -20(%rbp)
	movl	%esi, -24(%rbp)
	movl	-20(%rbp), %eax
	cmpl	-24(%rbp), %eax
	jge	.L9
	movl	pos(%rip), %eax
	leal	1(%rax), %edx
	movl	%edx, pos(%rip)
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	pre(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -8(%rbp)
	movl	-8(%rbp), %eax
	movl	%eax, %esi
	leaq	in(%rip), %rax
	movq	%rax, %rdi
	call	find
	movl	%eax, -4(%rbp)
	movl	-4(%rbp), %edx
	movl	-20(%rbp), %eax
	movl	%edx, %esi
	movl	%eax, %edi
	call	rec
	movl	-4(%rbp), %eax
	leal	1(%rax), %edx
	movl	-24(%rbp), %eax
	movl	%eax, %esi
	movl	%edx, %edi
	call	rec
	movl	count(%rip), %eax
	leal	1(%rax), %edx
	movl	%edx, count(%rip)
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	post(%rip), %rdx
	movl	-8(%rbp), %eax
	movl	%eax, (%rcx,%rdx)
	jmp	.L6
.L9:
	nop
.L6:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.size	rec, .-rec
	.section	.rodata
.LC0:
	.string	"%d"
	.text
	.globl	solve
	.type	solve, @function
solve:
.LFB2:
	.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	$0, pos(%rip)
	movl	n(%rip), %eax
	movl	%eax, %esi
	movl	$0, %edi
	call	rec
	movl	$0, -4(%rbp)
	jmp	.L11
.L13:
	cmpl	$0, -4(%rbp)
	je	.L12
	movl	$32, %edi
	call	putchar@PLT
.L12:
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	post(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, %esi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	addl	$1, -4(%rbp)
.L11:
	movl	n(%rip), %eax
	cmpl	%eax, -4(%rbp)
	jl	.L13
	movl	$10, %edi
	call	putchar@PLT
	nop
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE2:
	.size	solve, .-solve
	.globl	main
	.type	main, @function
main:
.LFB3:
	.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	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	n(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -12(%rbp)
	jmp	.L15
.L16:
	leaq	-16(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-16(%rbp), %eax
	movl	-12(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	pre(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	addl	$1, -12(%rbp)
.L15:
	movl	n(%rip), %eax
	cmpl	%eax, -12(%rbp)
	jl	.L16
	movl	$0, -12(%rbp)
	jmp	.L17
.L18:
	leaq	-16(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-16(%rbp), %eax
	movl	-12(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	in(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	addl	$1, -12(%rbp)
.L17:
	movl	n(%rip), %eax
	cmpl	%eax, -12(%rbp)
	jl	.L18
	movl	$0, %eax
	call	solve
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L20
	call	__stack_chk_fail@PLT
.L20:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE3:
	.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:
