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>

struct Node{
  int key;
  struct Node *r,*l,*p;
};

 struct Node *B,*NIL;

void insert(int k){
   struct Node *y = NIL;
   struct Node *x = B;
   struct Node *z;

   z = (struct Node *)malloc(sizeof(struct Node));
   z->key = k;
   z->l = NIL;
   z->r = NIL;

   while(x!=NIL){
     y = x;
     
     if(z->key < x->key){
       x = x->l;
     }
     else x = x->r;
   }
   
   z->p = y;
   if(y == NIL ){
     B=z;
   }
   else if(z->key < y->key){
       y->l = z;
     }
   else y->r = z;
}




void inorder(struct Node *u){
  if(u==NIL) return;
  inorder(u->l);
  printf(" %d",u->key);
  inorder(u->r);
}

void preorder(struct Node *u){
  if(u == NIL )return;
  printf(" %d",u->key);
  preorder(u->l);
  preorder(u->r);
}

int main(){
  
  int i,x,y;
  char G[8];
  scanf("%d",&x);
  
  for(i=0;i<x;i++){
    scanf("%s",&G);
    
    if(G[0] == 'i'){
      scanf("%d",&y);
      insert(y);
    }
    
    else if(G[0] == 'p'){
      inorder(B);
      printf("\n");
      preorder(B);
      printf("\n");
    }
  }
  return 0;
}

  

```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	B
	.bss
	.align 8
	.type	B, @object
	.size	B, 8
B:
	.zero	8
	.globl	NIL
	.align 8
	.type	NIL, @object
	.size	NIL, 8
NIL:
	.zero	8
	.text
	.globl	insert
	.type	insert, @function
insert:
.LFB6:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$48, %rsp
	movl	%edi, -36(%rbp)
	movq	NIL(%rip), %rax
	movq	%rax, -24(%rbp)
	movq	B(%rip), %rax
	movq	%rax, -16(%rbp)
	movl	$32, %edi
	call	malloc@PLT
	movq	%rax, -8(%rbp)
	movq	-8(%rbp), %rax
	movl	-36(%rbp), %edx
	movl	%edx, (%rax)
	movq	NIL(%rip), %rdx
	movq	-8(%rbp), %rax
	movq	%rdx, 16(%rax)
	movq	NIL(%rip), %rdx
	movq	-8(%rbp), %rax
	movq	%rdx, 8(%rax)
	jmp	.L2
.L4:
	movq	-16(%rbp), %rax
	movq	%rax, -24(%rbp)
	movq	-8(%rbp), %rax
	movl	(%rax), %edx
	movq	-16(%rbp), %rax
	movl	(%rax), %eax
	cmpl	%eax, %edx
	jge	.L3
	movq	-16(%rbp), %rax
	movq	16(%rax), %rax
	movq	%rax, -16(%rbp)
	jmp	.L2
.L3:
	movq	-16(%rbp), %rax
	movq	8(%rax), %rax
	movq	%rax, -16(%rbp)
.L2:
	movq	NIL(%rip), %rax
	cmpq	%rax, -16(%rbp)
	jne	.L4
	movq	-8(%rbp), %rax
	movq	-24(%rbp), %rdx
	movq	%rdx, 24(%rax)
	movq	NIL(%rip), %rax
	cmpq	%rax, -24(%rbp)
	jne	.L5
	movq	-8(%rbp), %rax
	movq	%rax, B(%rip)
	jmp	.L8
.L5:
	movq	-8(%rbp), %rax
	movl	(%rax), %edx
	movq	-24(%rbp), %rax
	movl	(%rax), %eax
	cmpl	%eax, %edx
	jge	.L7
	movq	-24(%rbp), %rax
	movq	-8(%rbp), %rdx
	movq	%rdx, 16(%rax)
	jmp	.L8
.L7:
	movq	-24(%rbp), %rax
	movq	-8(%rbp), %rdx
	movq	%rdx, 8(%rax)
.L8:
	nop
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	insert, .-insert
	.section	.rodata
.LC0:
	.string	" %d"
	.text
	.globl	inorder
	.type	inorder, @function
inorder:
.LFB7:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$16, %rsp
	movq	%rdi, -8(%rbp)
	movq	NIL(%rip), %rax
	cmpq	%rax, -8(%rbp)
	je	.L12
	movq	-8(%rbp), %rax
	movq	16(%rax), %rax
	movq	%rax, %rdi
	call	inorder
	movq	-8(%rbp), %rax
	movl	(%rax), %eax
	movl	%eax, %esi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movq	-8(%rbp), %rax
	movq	8(%rax), %rax
	movq	%rax, %rdi
	call	inorder
	jmp	.L9
.L12:
	nop
.L9:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.size	inorder, .-inorder
	.globl	preorder
	.type	preorder, @function
preorder:
.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	NIL(%rip), %rax
	cmpq	%rax, -8(%rbp)
	je	.L16
	movq	-8(%rbp), %rax
	movl	(%rax), %eax
	movl	%eax, %esi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movq	-8(%rbp), %rax
	movq	16(%rax), %rax
	movq	%rax, %rdi
	call	preorder
	movq	-8(%rbp), %rax
	movq	8(%rax), %rax
	movq	%rax, %rdi
	call	preorder
	jmp	.L13
.L16:
	nop
.L13:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE8:
	.size	preorder, .-preorder
	.section	.rodata
.LC1:
	.string	"%d"
.LC2:
	.string	"%s"
	.text
	.globl	main
	.type	main, @function
main:
.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	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-28(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -20(%rbp)
	jmp	.L18
.L21:
	leaq	-16(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movzbl	-16(%rbp), %eax
	cmpb	$105, %al
	jne	.L19
	leaq	-24(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-24(%rbp), %eax
	movl	%eax, %edi
	call	insert
	jmp	.L20
.L19:
	movzbl	-16(%rbp), %eax
	cmpb	$112, %al
	jne	.L20
	movq	B(%rip), %rax
	movq	%rax, %rdi
	call	inorder
	movl	$10, %edi
	call	putchar@PLT
	movq	B(%rip), %rax
	movq	%rax, %rdi
	call	preorder
	movl	$10, %edi
	call	putchar@PLT
.L20:
	addl	$1, -20(%rbp)
.L18:
	movl	-28(%rbp), %eax
	cmpl	%eax, -20(%rbp)
	jl	.L21
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L23
	call	__stack_chk_fail@PLT
.L23:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE9:
	.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	insert
	.type	insert, @function
insert:
.LFB39:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	movl	%edi, %r12d
	movl	$32, %edi
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	movq	NIL(%rip), %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	movq	B(%rip), %rbx
	call	malloc@PLT
	movq	%rbp, %xmm0
	punpcklqdq	%xmm0, %xmm0
	movl	%r12d, (%rax)
	movups	%xmm0, 8(%rax)
	cmpq	%rbx, %rbp
	je	.L2
	.p2align 4,,10
	.p2align 3
.L7:
	movq	8(%rbx), %rcx
	movq	16(%rbx), %rdx
	cmpl	%r12d, (%rbx)
	jle	.L3
.L19:
	cmpq	%rdx, %rbp
	je	.L18
	movq	%rdx, %rbx
	movq	8(%rbx), %rcx
	movq	16(%rbx), %rdx
	cmpl	%r12d, (%rbx)
	jg	.L19
.L3:
	cmpq	%rcx, %rbp
	je	.L6
	movq	%rcx, %rbx
	jmp	.L7
	.p2align 4,,10
	.p2align 3
.L18:
	movq	%rbx, 24(%rax)
	cmpq	%rbx, %rbp
	je	.L9
	movq	%rax, 16(%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
.L6:
	.cfi_restore_state
	movq	%rbx, 24(%rax)
	cmpq	%rbx, %rbp
	je	.L9
	movq	%rax, 8(%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
.L2:
	.cfi_restore_state
	movq	%rbp, 24(%rax)
.L9:
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%rbp
	.cfi_def_cfa_offset 16
	movq	%rax, B(%rip)
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE39:
	.size	insert, .-insert
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	" %d"
	.text
	.p2align 4
	.globl	inorder
	.type	inorder, @function
inorder:
.LFB40:
	.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
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$40, %rsp
	.cfi_def_cfa_offset 96
	movq	NIL(%rip), %rax
	movq	%rdi, 16(%rsp)
	cmpq	%rax, %rdi
	je	.L20
	leaq	.LC0(%rip), %rbp
.L21:
	movq	16(%rsp), %rsi
	movq	16(%rsi), %rcx
	movq	%rcx, (%rsp)
	cmpq	%rax, %rcx
	je	.L25
.L22:
	movq	(%rsp), %rcx
	movq	16(%rcx), %rdx
	movq	%rdx, 8(%rsp)
	cmpq	%rax, %rdx
	je	.L27
.L24:
	movq	8(%rsp), %rdi
	movq	16(%rdi), %r15
	cmpq	%rax, %r15
	je	.L29
.L26:
	movq	16(%r15), %rbx
	cmpq	%rax, %rbx
	je	.L31
.L28:
	movq	16(%rbx), %r13
	cmpq	%rax, %r13
	je	.L33
.L30:
	movq	16(%r13), %r12
	cmpq	%rax, %r12
	je	.L35
.L32:
	movq	16(%r12), %r14
	cmpq	%rax, %r14
	je	.L37
.L34:
	movq	16(%r14), %r9
	cmpq	%rax, %r9
	je	.L38
.L36:
	movq	16(%r9), %rdi
	movq	%r9, 24(%rsp)
	call	inorder
	movq	24(%rsp), %r9
	xorl	%eax, %eax
	movq	%rbp, %rsi
	movl	$1, %edi
	movl	(%r9), %edx
	call	__printf_chk@PLT
	movq	24(%rsp), %r9
	movq	8(%r9), %r9
	cmpq	%r9, NIL(%rip)
	jne	.L36
.L38:
	movl	(%r14), %edx
	movq	%rbp, %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	8(%r14), %r14
	movq	NIL(%rip), %rax
	cmpq	%r14, %rax
	jne	.L34
.L37:
	movl	(%r12), %edx
	movq	%rbp, %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	8(%r12), %r12
	movq	NIL(%rip), %rax
	cmpq	%r12, %rax
	jne	.L32
.L35:
	movl	0(%r13), %edx
	movq	%rbp, %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	8(%r13), %r13
	movq	NIL(%rip), %rax
	cmpq	%r13, %rax
	jne	.L30
.L33:
	movl	(%rbx), %edx
	movq	%rbp, %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	8(%rbx), %rbx
	movq	NIL(%rip), %rax
	cmpq	%rbx, %rax
	jne	.L28
.L31:
	movl	(%r15), %edx
	movq	%rbp, %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	8(%r15), %r15
	movq	NIL(%rip), %rax
	cmpq	%r15, %rax
	jne	.L26
.L29:
	movq	8(%rsp), %rbx
	movq	%rbp, %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	movl	(%rbx), %edx
	call	__printf_chk@PLT
	movq	8(%rbx), %rcx
	movq	NIL(%rip), %rax
	movq	%rcx, 8(%rsp)
	cmpq	%rcx, %rax
	jne	.L24
.L27:
	movq	(%rsp), %rbx
	movq	%rbp, %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	movl	(%rbx), %edx
	call	__printf_chk@PLT
	movq	8(%rbx), %rsi
	movq	NIL(%rip), %rax
	movq	%rsi, (%rsp)
	cmpq	%rsi, %rax
	jne	.L22
.L25:
	movq	16(%rsp), %rbx
	movq	%rbp, %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	movl	(%rbx), %edx
	call	__printf_chk@PLT
	movq	8(%rbx), %rcx
	movq	NIL(%rip), %rax
	movq	%rcx, 16(%rsp)
	cmpq	%rcx, %rax
	jne	.L21
.L20:
	addq	$40, %rsp
	.cfi_def_cfa_offset 56
	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
	.cfi_endproc
.LFE40:
	.size	inorder, .-inorder
	.p2align 4
	.globl	preorder
	.type	preorder, @function
preorder:
.LFB41:
	.cfi_startproc
	endbr64
	cmpq	NIL(%rip), %rdi
	je	.L82
	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
	movq	%rdi, %r12
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	leaq	.LC0(%rip), %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$40, %rsp
	.cfi_def_cfa_offset 96
.L51:
	movl	(%r12), %edx
	movq	%rbp, %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	16(%r12), %rax
	movq	NIL(%rip), %r14
	movq	%rax, (%rsp)
	cmpq	%r14, %rax
	je	.L52
.L67:
	movq	(%rsp), %rbx
	movq	%rbp, %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	movl	(%rbx), %edx
	call	__printf_chk@PLT
	movq	16(%rbx), %rax
	movq	NIL(%rip), %r14
	movq	%rax, 8(%rsp)
	cmpq	%r14, %rax
	je	.L53
.L66:
	movq	8(%rsp), %rbx
	movq	%rbp, %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	movl	(%rbx), %edx
	call	__printf_chk@PLT
	movq	16(%rbx), %rax
	movq	NIL(%rip), %r14
	movq	%rax, 16(%rsp)
	cmpq	%r14, %rax
	je	.L54
.L65:
	movq	16(%rsp), %rbx
	movq	%rbp, %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	movl	(%rbx), %edx
	call	__printf_chk@PLT
	movq	16(%rbx), %rbx
	movq	NIL(%rip), %r14
	cmpq	%r14, %rbx
	je	.L55
.L64:
	movl	(%rbx), %edx
	xorl	%eax, %eax
	movq	%rbp, %rsi
	movl	$1, %edi
	call	__printf_chk@PLT
	movq	16(%rbx), %r15
	cmpq	%r15, NIL(%rip)
	movq	%r15, %r14
	je	.L56
.L63:
	movl	(%r15), %edx
	movq	%rbp, %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	16(%r15), %r13
	movq	NIL(%rip), %r14
	cmpq	%r14, %r13
	je	.L57
.L62:
	movl	0(%r13), %edx
	movq	%rbp, %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	16(%r13), %rax
	movq	NIL(%rip), %r14
	cmpq	%r14, %rax
	je	.L58
	movq	%rax, %r14
.L61:
	movl	(%r14), %edx
	xorl	%eax, %eax
	movq	%rbp, %rsi
	movl	$1, %edi
	call	__printf_chk@PLT
	movq	16(%r14), %r9
	cmpq	NIL(%rip), %r9
	je	.L59
.L60:
	movl	(%r9), %edx
	movq	%rbp, %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	movq	%r9, 24(%rsp)
	call	__printf_chk@PLT
	movq	24(%rsp), %r9
	movq	16(%r9), %rdi
	call	preorder
	movq	24(%rsp), %r9
	movq	8(%r9), %r9
	cmpq	%r9, NIL(%rip)
	jne	.L60
.L59:
	movq	8(%r14), %r14
	cmpq	%r14, %r9
	jne	.L61
.L58:
	movq	8(%r13), %r13
	cmpq	%r14, %r13
	jne	.L62
.L57:
	movq	8(%r15), %r15
	cmpq	%r14, %r15
	jne	.L63
.L56:
	movq	8(%rbx), %rbx
	cmpq	%r14, %rbx
	jne	.L64
.L55:
	movq	16(%rsp), %rax
	movq	8(%rax), %rax
	movq	%rax, 16(%rsp)
	cmpq	%r14, %rax
	jne	.L65
.L54:
	movq	8(%rsp), %rax
	movq	8(%rax), %rax
	movq	%rax, 8(%rsp)
	cmpq	%r14, %rax
	jne	.L66
.L53:
	movq	(%rsp), %rax
	movq	8(%rax), %rax
	movq	%rax, (%rsp)
	cmpq	%r14, %rax
	jne	.L67
.L52:
	movq	8(%r12), %r12
	cmpq	%r14, %r12
	jne	.L51
	addq	$40, %rsp
	.cfi_def_cfa_offset 56
	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
.L82:
	.cfi_restore 3
	.cfi_restore 6
	.cfi_restore 12
	.cfi_restore 13
	.cfi_restore 14
	.cfi_restore 15
	ret
	.cfi_endproc
.LFE41:
	.size	preorder, .-preorder
	.section	.rodata.str1.1
.LC1:
	.string	"%d"
.LC2:
	.string	"%s"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB42:
	.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
	leaq	.LC1(%rip), %r13
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	movq	%r13, %rdi
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$56, %rsp
	.cfi_def_cfa_offset 112
	movq	%fs:40, %rax
	movq	%rax, 40(%rsp)
	xorl	%eax, %eax
	leaq	24(%rsp), %rsi
	call	__isoc99_scanf@PLT
	movl	24(%rsp), %eax
	testl	%eax, %eax
	jle	.L95
	xorl	%r15d, %r15d
	leaq	32(%rsp), %r12
	leaq	28(%rsp), %r14
	leaq	.LC2(%rip), %rbp
	jmp	.L86
	.p2align 4,,10
	.p2align 3
.L87:
	cmpb	$112, %al
	je	.L110
.L94:
	addl	$1, %r15d
	cmpl	%r15d, 24(%rsp)
	jle	.L95
.L86:
	movq	%r12, %rsi
	movq	%rbp, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movzbl	32(%rsp), %eax
	cmpb	$105, %al
	jne	.L87
	movq	%r14, %rsi
	movq	%r13, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	28(%rsp), %r8d
	movq	NIL(%rip), %rsi
	movl	$32, %edi
	movq	B(%rip), %rbx
	movl	%r8d, 12(%rsp)
	movq	%rsi, (%rsp)
	call	malloc@PLT
	movq	(%rsp), %rsi
	movl	12(%rsp), %r8d
	movq	%rsi, %xmm0
	movl	%r8d, (%rax)
	punpcklqdq	%xmm0, %xmm0
	movups	%xmm0, 8(%rax)
	cmpq	%rbx, %rsi
	je	.L88
	.p2align 4,,10
	.p2align 3
.L93:
	movq	8(%rbx), %rcx
	movq	16(%rbx), %rdx
	cmpl	(%rbx), %r8d
	jge	.L89
.L112:
	cmpq	%rdx, %rsi
	je	.L111
	movq	%rdx, %rbx
	movq	8(%rbx), %rcx
	movq	16(%rbx), %rdx
	cmpl	(%rbx), %r8d
	jl	.L112
.L89:
	cmpq	%rcx, %rsi
	je	.L92
	movq	%rcx, %rbx
	jmp	.L93
	.p2align 4,,10
	.p2align 3
.L110:
	movq	B(%rip), %rdi
	addl	$1, %r15d
	call	inorder
	movl	$10, %edi
	call	putchar@PLT
	movq	B(%rip), %rdi
	call	preorder
	movl	$10, %edi
	call	putchar@PLT
	cmpl	%r15d, 24(%rsp)
	jg	.L86
	.p2align 4,,10
	.p2align 3
.L95:
	movq	40(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L113
	addq	$56, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 56
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L111:
	.cfi_restore_state
	movq	%rbx, 24(%rax)
	cmpq	%rsi, %rbx
	je	.L96
	movq	%rax, 16(%rbx)
	jmp	.L94
	.p2align 4,,10
	.p2align 3
.L92:
	movq	%rbx, 24(%rax)
	cmpq	%rsi, %rbx
	je	.L96
	movq	%rax, 8(%rbx)
	jmp	.L94
.L88:
	movq	%rsi, 24(%rax)
.L96:
	movq	%rax, B(%rip)
	jmp	.L94
.L113:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE42:
	.size	main, .-main
	.globl	NIL
	.bss
	.align 8
	.type	NIL, @object
	.size	NIL, 8
NIL:
	.zero	8
	.globl	B
	.align 8
	.type	B, @object
	.size	B, 8
B:
	.zero	8
	.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	insert
	.type	insert, @function
insert:
.LFB39:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	movl	%edi, %r12d
	movl	$32, %edi
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	movq	NIL(%rip), %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	movq	B(%rip), %rbx
	call	malloc@PLT
	movq	%rbp, %xmm0
	punpcklqdq	%xmm0, %xmm0
	movl	%r12d, (%rax)
	movups	%xmm0, 8(%rax)
	cmpq	%rbx, %rbp
	je	.L2
	.p2align 4,,10
	.p2align 3
.L7:
	movq	8(%rbx), %rcx
	movq	16(%rbx), %rdx
	cmpl	%r12d, (%rbx)
	jle	.L3
.L19:
	cmpq	%rdx, %rbp
	je	.L18
	movq	%rdx, %rbx
	movq	8(%rbx), %rcx
	movq	16(%rbx), %rdx
	cmpl	%r12d, (%rbx)
	jg	.L19
.L3:
	cmpq	%rcx, %rbp
	je	.L6
	movq	%rcx, %rbx
	jmp	.L7
	.p2align 4,,10
	.p2align 3
.L18:
	movq	%rbx, 24(%rax)
	cmpq	%rbx, %rbp
	je	.L9
	movq	%rax, 16(%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
.L6:
	.cfi_restore_state
	movq	%rbx, 24(%rax)
	cmpq	%rbx, %rbp
	je	.L9
	movq	%rax, 8(%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
.L2:
	.cfi_restore_state
	movq	%rbp, 24(%rax)
.L9:
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%rbp
	.cfi_def_cfa_offset 16
	movq	%rax, B(%rip)
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE39:
	.size	insert, .-insert
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	" %d"
	.text
	.p2align 4
	.globl	inorder
	.type	inorder, @function
inorder:
.LFB40:
	.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
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$40, %rsp
	.cfi_def_cfa_offset 96
	movq	NIL(%rip), %rax
	movq	%rdi, 16(%rsp)
	cmpq	%rax, %rdi
	je	.L20
	leaq	.LC0(%rip), %rbp
.L21:
	movq	16(%rsp), %rsi
	movq	16(%rsi), %rcx
	movq	%rcx, (%rsp)
	cmpq	%rax, %rcx
	je	.L25
.L22:
	movq	(%rsp), %rcx
	movq	16(%rcx), %rdx
	movq	%rdx, 8(%rsp)
	cmpq	%rax, %rdx
	je	.L27
.L24:
	movq	8(%rsp), %rdi
	movq	16(%rdi), %r15
	cmpq	%rax, %r15
	je	.L29
.L26:
	movq	16(%r15), %rbx
	cmpq	%rax, %rbx
	je	.L31
.L28:
	movq	16(%rbx), %r13
	cmpq	%rax, %r13
	je	.L33
.L30:
	movq	16(%r13), %r12
	cmpq	%rax, %r12
	je	.L35
.L32:
	movq	16(%r12), %r14
	cmpq	%rax, %r14
	je	.L37
.L34:
	movq	16(%r14), %r9
	cmpq	%rax, %r9
	je	.L38
.L36:
	movq	16(%r9), %rdi
	movq	%r9, 24(%rsp)
	call	inorder
	movq	24(%rsp), %r9
	xorl	%eax, %eax
	movq	%rbp, %rsi
	movl	$1, %edi
	movl	(%r9), %edx
	call	__printf_chk@PLT
	movq	24(%rsp), %r9
	movq	8(%r9), %r9
	cmpq	%r9, NIL(%rip)
	jne	.L36
.L38:
	movl	(%r14), %edx
	movq	%rbp, %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	8(%r14), %r14
	movq	NIL(%rip), %rax
	cmpq	%r14, %rax
	jne	.L34
.L37:
	movl	(%r12), %edx
	movq	%rbp, %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	8(%r12), %r12
	movq	NIL(%rip), %rax
	cmpq	%r12, %rax
	jne	.L32
.L35:
	movl	0(%r13), %edx
	movq	%rbp, %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	8(%r13), %r13
	movq	NIL(%rip), %rax
	cmpq	%r13, %rax
	jne	.L30
.L33:
	movl	(%rbx), %edx
	movq	%rbp, %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	8(%rbx), %rbx
	movq	NIL(%rip), %rax
	cmpq	%rbx, %rax
	jne	.L28
.L31:
	movl	(%r15), %edx
	movq	%rbp, %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	8(%r15), %r15
	movq	NIL(%rip), %rax
	cmpq	%r15, %rax
	jne	.L26
.L29:
	movq	8(%rsp), %rbx
	movq	%rbp, %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	movl	(%rbx), %edx
	call	__printf_chk@PLT
	movq	8(%rbx), %rcx
	movq	NIL(%rip), %rax
	movq	%rcx, 8(%rsp)
	cmpq	%rcx, %rax
	jne	.L24
.L27:
	movq	(%rsp), %rbx
	movq	%rbp, %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	movl	(%rbx), %edx
	call	__printf_chk@PLT
	movq	8(%rbx), %rsi
	movq	NIL(%rip), %rax
	movq	%rsi, (%rsp)
	cmpq	%rsi, %rax
	jne	.L22
.L25:
	movq	16(%rsp), %rbx
	movq	%rbp, %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	movl	(%rbx), %edx
	call	__printf_chk@PLT
	movq	8(%rbx), %rcx
	movq	NIL(%rip), %rax
	movq	%rcx, 16(%rsp)
	cmpq	%rcx, %rax
	jne	.L21
.L20:
	addq	$40, %rsp
	.cfi_def_cfa_offset 56
	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
	.cfi_endproc
.LFE40:
	.size	inorder, .-inorder
	.p2align 4
	.globl	preorder
	.type	preorder, @function
preorder:
.LFB41:
	.cfi_startproc
	endbr64
	cmpq	NIL(%rip), %rdi
	je	.L82
	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
	movq	%rdi, %r12
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	leaq	.LC0(%rip), %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$40, %rsp
	.cfi_def_cfa_offset 96
.L51:
	movl	(%r12), %edx
	movq	%rbp, %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	16(%r12), %rax
	movq	NIL(%rip), %r14
	movq	%rax, (%rsp)
	cmpq	%r14, %rax
	je	.L52
.L67:
	movq	(%rsp), %rbx
	movq	%rbp, %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	movl	(%rbx), %edx
	call	__printf_chk@PLT
	movq	16(%rbx), %rax
	movq	NIL(%rip), %r14
	movq	%rax, 8(%rsp)
	cmpq	%r14, %rax
	je	.L53
.L66:
	movq	8(%rsp), %rbx
	movq	%rbp, %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	movl	(%rbx), %edx
	call	__printf_chk@PLT
	movq	16(%rbx), %rax
	movq	NIL(%rip), %r14
	movq	%rax, 16(%rsp)
	cmpq	%r14, %rax
	je	.L54
.L65:
	movq	16(%rsp), %rbx
	movq	%rbp, %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	movl	(%rbx), %edx
	call	__printf_chk@PLT
	movq	16(%rbx), %rbx
	movq	NIL(%rip), %r14
	cmpq	%r14, %rbx
	je	.L55
.L64:
	movl	(%rbx), %edx
	xorl	%eax, %eax
	movq	%rbp, %rsi
	movl	$1, %edi
	call	__printf_chk@PLT
	movq	16(%rbx), %r15
	cmpq	%r15, NIL(%rip)
	movq	%r15, %r14
	je	.L56
.L63:
	movl	(%r15), %edx
	movq	%rbp, %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	16(%r15), %r13
	movq	NIL(%rip), %r14
	cmpq	%r14, %r13
	je	.L57
.L62:
	movl	0(%r13), %edx
	movq	%rbp, %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	16(%r13), %rax
	movq	NIL(%rip), %r14
	cmpq	%r14, %rax
	je	.L58
	movq	%rax, %r14
.L61:
	movl	(%r14), %edx
	xorl	%eax, %eax
	movq	%rbp, %rsi
	movl	$1, %edi
	call	__printf_chk@PLT
	movq	16(%r14), %r9
	cmpq	NIL(%rip), %r9
	je	.L59
.L60:
	movl	(%r9), %edx
	movq	%rbp, %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	movq	%r9, 24(%rsp)
	call	__printf_chk@PLT
	movq	24(%rsp), %r9
	movq	16(%r9), %rdi
	call	preorder
	movq	24(%rsp), %r9
	movq	8(%r9), %r9
	cmpq	%r9, NIL(%rip)
	jne	.L60
.L59:
	movq	8(%r14), %r14
	cmpq	%r14, %r9
	jne	.L61
.L58:
	movq	8(%r13), %r13
	cmpq	%r14, %r13
	jne	.L62
.L57:
	movq	8(%r15), %r15
	cmpq	%r14, %r15
	jne	.L63
.L56:
	movq	8(%rbx), %rbx
	cmpq	%r14, %rbx
	jne	.L64
.L55:
	movq	16(%rsp), %rax
	movq	8(%rax), %rax
	movq	%rax, 16(%rsp)
	cmpq	%r14, %rax
	jne	.L65
.L54:
	movq	8(%rsp), %rax
	movq	8(%rax), %rax
	movq	%rax, 8(%rsp)
	cmpq	%r14, %rax
	jne	.L66
.L53:
	movq	(%rsp), %rax
	movq	8(%rax), %rax
	movq	%rax, (%rsp)
	cmpq	%r14, %rax
	jne	.L67
.L52:
	movq	8(%r12), %r12
	cmpq	%r14, %r12
	jne	.L51
	addq	$40, %rsp
	.cfi_def_cfa_offset 56
	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
.L82:
	.cfi_restore 3
	.cfi_restore 6
	.cfi_restore 12
	.cfi_restore 13
	.cfi_restore 14
	.cfi_restore 15
	ret
	.cfi_endproc
.LFE41:
	.size	preorder, .-preorder
	.section	.rodata.str1.1
.LC1:
	.string	"%d"
.LC2:
	.string	"%s"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB42:
	.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
	leaq	.LC1(%rip), %r13
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	movq	%r13, %rdi
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$56, %rsp
	.cfi_def_cfa_offset 112
	movq	%fs:40, %rax
	movq	%rax, 40(%rsp)
	xorl	%eax, %eax
	leaq	24(%rsp), %rsi
	call	__isoc99_scanf@PLT
	movl	24(%rsp), %eax
	testl	%eax, %eax
	jle	.L95
	xorl	%r15d, %r15d
	leaq	32(%rsp), %r12
	leaq	28(%rsp), %r14
	leaq	.LC2(%rip), %rbp
	jmp	.L86
	.p2align 4,,10
	.p2align 3
.L87:
	cmpb	$112, %al
	je	.L110
.L94:
	addl	$1, %r15d
	cmpl	%r15d, 24(%rsp)
	jle	.L95
.L86:
	movq	%r12, %rsi
	movq	%rbp, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movzbl	32(%rsp), %eax
	cmpb	$105, %al
	jne	.L87
	movq	%r14, %rsi
	movq	%r13, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	28(%rsp), %r8d
	movq	NIL(%rip), %rsi
	movl	$32, %edi
	movq	B(%rip), %rbx
	movl	%r8d, 12(%rsp)
	movq	%rsi, (%rsp)
	call	malloc@PLT
	movq	(%rsp), %rsi
	movl	12(%rsp), %r8d
	movq	%rsi, %xmm0
	movl	%r8d, (%rax)
	punpcklqdq	%xmm0, %xmm0
	movups	%xmm0, 8(%rax)
	cmpq	%rbx, %rsi
	je	.L88
	.p2align 4,,10
	.p2align 3
.L93:
	movq	8(%rbx), %rcx
	movq	16(%rbx), %rdx
	cmpl	(%rbx), %r8d
	jge	.L89
.L112:
	cmpq	%rdx, %rsi
	je	.L111
	movq	%rdx, %rbx
	movq	8(%rbx), %rcx
	movq	16(%rbx), %rdx
	cmpl	(%rbx), %r8d
	jl	.L112
.L89:
	cmpq	%rcx, %rsi
	je	.L92
	movq	%rcx, %rbx
	jmp	.L93
	.p2align 4,,10
	.p2align 3
.L110:
	movq	B(%rip), %rdi
	addl	$1, %r15d
	call	inorder
	movl	$10, %edi
	call	putchar@PLT
	movq	B(%rip), %rdi
	call	preorder
	movl	$10, %edi
	call	putchar@PLT
	cmpl	%r15d, 24(%rsp)
	jg	.L86
	.p2align 4,,10
	.p2align 3
.L95:
	movq	40(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L113
	addq	$56, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 56
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L111:
	.cfi_restore_state
	movq	%rbx, 24(%rax)
	cmpq	%rsi, %rbx
	je	.L96
	movq	%rax, 16(%rbx)
	jmp	.L94
	.p2align 4,,10
	.p2align 3
.L92:
	movq	%rbx, 24(%rax)
	cmpq	%rsi, %rbx
	je	.L96
	movq	%rax, 8(%rbx)
	jmp	.L94
.L88:
	movq	%rsi, 24(%rax)
.L96:
	movq	%rax, B(%rip)
	jmp	.L94
.L113:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE42:
	.size	main, .-main
	.globl	NIL
	.bss
	.align 8
	.type	NIL, @object
	.size	NIL, 8
NIL:
	.zero	8
	.globl	B
	.align 8
	.type	B, @object
	.size	B, 8
B:
	.zero	8
	.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>

struct Node{
  int key;
  struct Node *r,*l,*p;
};

 struct Node *B,*NIL;

void insert(int k){
   struct Node *y = NIL;
   struct Node *x = B;
   struct Node *z;

   z = (struct Node *)malloc(sizeof(struct Node));
   z->key = k;
   z->l = NIL;
   z->r = NIL;

   while(x!=NIL){
     y = x;
     
     if(z->key < x->key){
       x = x->l;
     }
     else x = x->r;
   }
   
   z->p = y;
   if(y == NIL ){
     B=z;
   }
   else if(z->key < y->key){
       y->l = z;
     }
   else y->r = z;
}




void inorder(struct Node *u){
  if(u==NIL) return;
  inorder(u->l);
  printf(" %d",u->key);
  inorder(u->r);
}

void preorder(struct Node *u){
  if(u == NIL )return;
  printf(" %d",u->key);
  preorder(u->l);
  preorder(u->r);
}

int main(){
  
  int i,x,y;
  char G[8];
  scanf("%d",&x);
  
  for(i=0;i<x;i++){
    scanf("%s",&G);
    
    if(G[0] == 'i'){
      scanf("%d",&y);
      insert(y);
    }
    
    else if(G[0] == 'p'){
      inorder(B);
      printf("\n");
      preorder(B);
      printf("\n");
    }
  }
  return 0;
}

  


8
insert 30
insert 88
insert 18
insert 1
insert 20
insert 17
insert 25
print
 8
insert 30
insert 113
insert 18
insert 1
insert 20
insert 17
insert 25
print
 8
insert 30
insert 88
insert 18
insert 1
insert 20
insert 21
insert 25
print
 8
insert 30
insert 88
insert 24
insert 1
insert 20
insert 21
insert 25
print
 8
insert 30
insert 88
insert 24
insert 1
insert 20
insert 21
insert 16
print
 8
insert 30
insert 99
insert 12
insert 1
insert 20
insert 17
insert 25
print
 8
insert 30
insert 88
insert 18
insert 0
insert 20
insert 21
insert 25
print
 8
insert 30
insert 99
insert 12
insert 1
insert 20
insert 17
insert 19
print
 8
insert 30
insert 88
insert 12
insert 1
insert 32
insert 17
insert 25
print
 8
insert 30
insert 93
insert 18
insert 1
insert 20
insert 17
insert 25
print

 1 17 18 20 25 30 88
 30 18 1 17 20 25 88
  1 17 18 20 25 30 113
 30 18 1 17 20 25 113
  1 18 20 21 25 30 88
 30 18 1 20 21 25 88
  1 20 21 24 25 30 88
 30 24 1 20 21 25 88
  1 16 20 21 24 30 88
 30 24 1 20 16 21 88
  1 12 17 20 25 30 99
 30 12 1 20 17 25 99
  0 18 20 21 25 30 88
 30 18 0 20 21 25 88
  1 12 17 19 20 30 99
 30 12 1 20 17 19 99
  1 12 17 25 30 32 88
 30 12 1 17 25 88 32
  1 17 18 20 25 30 93
 30 18 1 17 20 25 93

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>

struct Node{
  int key;
  struct Node *r,*l,*p;
};

 struct Node *B,*NIL;

void insert(int k){
   struct Node *y = NIL;
   struct Node *x = B;
   struct Node *z;

   z = (struct Node *)malloc(sizeof(struct Node));
   z->key = k;
   z->l = NIL;
   z->r = NIL;

   while(x!=NIL){
     y = x;
     
     if(z->key < x->key){
       x = x->l;
     }
     else x = x->r;
   }
   
   z->p = y;
   if(y == NIL ){
     B=z;
   }
   else if(z->key < y->key){
       y->l = z;
     }
   else y->r = z;
}




void inorder(struct Node *u){
  if(u==NIL) return;
  inorder(u->l);
  printf(" %d",u->key);
  inorder(u->r);
}

void preorder(struct Node *u){
  if(u == NIL )return;
  printf(" %d",u->key);
  preorder(u->l);
  preorder(u->r);
}

int main(){
  
  int i,x,y;
  char G[8];
  scanf("%d",&x);
  
  for(i=0;i<x;i++){
    scanf("%s",&G);
    
    if(G[0] == 'i'){
      scanf("%d",&y);
      insert(y);
    }
    
    else if(G[0] == 'p'){
      inorder(B);
      printf("\n");
      preorder(B);
      printf("\n");
    }
  }
  return 0;
}

  

```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	B
	.bss
	.align 8
	.type	B, @object
	.size	B, 8
B:
	.zero	8
	.globl	NIL
	.align 8
	.type	NIL, @object
	.size	NIL, 8
NIL:
	.zero	8
	.text
	.globl	insert
	.type	insert, @function
insert:
.LFB6:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$48, %rsp
	movl	%edi, -36(%rbp)
	movq	NIL(%rip), %rax
	movq	%rax, -24(%rbp)
	movq	B(%rip), %rax
	movq	%rax, -16(%rbp)
	movl	$32, %edi
	call	malloc@PLT
	movq	%rax, -8(%rbp)
	movq	-8(%rbp), %rax
	movl	-36(%rbp), %edx
	movl	%edx, (%rax)
	movq	NIL(%rip), %rdx
	movq	-8(%rbp), %rax
	movq	%rdx, 16(%rax)
	movq	NIL(%rip), %rdx
	movq	-8(%rbp), %rax
	movq	%rdx, 8(%rax)
	jmp	.L2
.L4:
	movq	-16(%rbp), %rax
	movq	%rax, -24(%rbp)
	movq	-8(%rbp), %rax
	movl	(%rax), %edx
	movq	-16(%rbp), %rax
	movl	(%rax), %eax
	cmpl	%eax, %edx
	jge	.L3
	movq	-16(%rbp), %rax
	movq	16(%rax), %rax
	movq	%rax, -16(%rbp)
	jmp	.L2
.L3:
	movq	-16(%rbp), %rax
	movq	8(%rax), %rax
	movq	%rax, -16(%rbp)
.L2:
	movq	NIL(%rip), %rax
	cmpq	%rax, -16(%rbp)
	jne	.L4
	movq	-8(%rbp), %rax
	movq	-24(%rbp), %rdx
	movq	%rdx, 24(%rax)
	movq	NIL(%rip), %rax
	cmpq	%rax, -24(%rbp)
	jne	.L5
	movq	-8(%rbp), %rax
	movq	%rax, B(%rip)
	jmp	.L8
.L5:
	movq	-8(%rbp), %rax
	movl	(%rax), %edx
	movq	-24(%rbp), %rax
	movl	(%rax), %eax
	cmpl	%eax, %edx
	jge	.L7
	movq	-24(%rbp), %rax
	movq	-8(%rbp), %rdx
	movq	%rdx, 16(%rax)
	jmp	.L8
.L7:
	movq	-24(%rbp), %rax
	movq	-8(%rbp), %rdx
	movq	%rdx, 8(%rax)
.L8:
	nop
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	insert, .-insert
	.section	.rodata
.LC0:
	.string	" %d"
	.text
	.globl	inorder
	.type	inorder, @function
inorder:
.LFB7:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$16, %rsp
	movq	%rdi, -8(%rbp)
	movq	NIL(%rip), %rax
	cmpq	%rax, -8(%rbp)
	je	.L12
	movq	-8(%rbp), %rax
	movq	16(%rax), %rax
	movq	%rax, %rdi
	call	inorder
	movq	-8(%rbp), %rax
	movl	(%rax), %eax
	movl	%eax, %esi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movq	-8(%rbp), %rax
	movq	8(%rax), %rax
	movq	%rax, %rdi
	call	inorder
	jmp	.L9
.L12:
	nop
.L9:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.size	inorder, .-inorder
	.globl	preorder
	.type	preorder, @function
preorder:
.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	NIL(%rip), %rax
	cmpq	%rax, -8(%rbp)
	je	.L16
	movq	-8(%rbp), %rax
	movl	(%rax), %eax
	movl	%eax, %esi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movq	-8(%rbp), %rax
	movq	16(%rax), %rax
	movq	%rax, %rdi
	call	preorder
	movq	-8(%rbp), %rax
	movq	8(%rax), %rax
	movq	%rax, %rdi
	call	preorder
	jmp	.L13
.L16:
	nop
.L13:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE8:
	.size	preorder, .-preorder
	.section	.rodata
.LC1:
	.string	"%d"
.LC2:
	.string	"%s"
	.text
	.globl	main
	.type	main, @function
main:
.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	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-28(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -20(%rbp)
	jmp	.L18
.L21:
	leaq	-16(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movzbl	-16(%rbp), %eax
	cmpb	$105, %al
	jne	.L19
	leaq	-24(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-24(%rbp), %eax
	movl	%eax, %edi
	call	insert
	jmp	.L20
.L19:
	movzbl	-16(%rbp), %eax
	cmpb	$112, %al
	jne	.L20
	movq	B(%rip), %rax
	movq	%rax, %rdi
	call	inorder
	movl	$10, %edi
	call	putchar@PLT
	movq	B(%rip), %rax
	movq	%rax, %rdi
	call	preorder
	movl	$10, %edi
	call	putchar@PLT
.L20:
	addl	$1, -20(%rbp)
.L18:
	movl	-28(%rbp), %eax
	cmpl	%eax, -20(%rbp)
	jl	.L21
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L23
	call	__stack_chk_fail@PLT
.L23:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE9:
	.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	B
	.bss
	.align 8
	.type	B, @object
	.size	B, 8
B:
	.zero	8
	.globl	NIL
	.align 8
	.type	NIL, @object
	.size	NIL, 8
NIL:
	.zero	8
	.text
	.globl	insert
	.type	insert, @function
insert:
.LFB6:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$48, %rsp
	movl	%edi, -36(%rbp)
	movq	NIL(%rip), %rax
	movq	%rax, -24(%rbp)
	movq	B(%rip), %rax
	movq	%rax, -16(%rbp)
	movl	$32, %edi
	call	malloc@PLT
	movq	%rax, -8(%rbp)
	movq	-8(%rbp), %rax
	movl	-36(%rbp), %edx
	movl	%edx, (%rax)
	movq	NIL(%rip), %rdx
	movq	-8(%rbp), %rax
	movq	%rdx, 16(%rax)
	movq	NIL(%rip), %rdx
	movq	-8(%rbp), %rax
	movq	%rdx, 8(%rax)
	jmp	.L2
.L4:
	movq	-16(%rbp), %rax
	movq	%rax, -24(%rbp)
	movq	-8(%rbp), %rax
	movl	(%rax), %edx
	movq	-16(%rbp), %rax
	movl	(%rax), %eax
	cmpl	%eax, %edx
	jge	.L3
	movq	-16(%rbp), %rax
	movq	16(%rax), %rax
	movq	%rax, -16(%rbp)
	jmp	.L2
.L3:
	movq	-16(%rbp), %rax
	movq	8(%rax), %rax
	movq	%rax, -16(%rbp)
.L2:
	movq	NIL(%rip), %rax
	cmpq	%rax, -16(%rbp)
	jne	.L4
	movq	-8(%rbp), %rax
	movq	-24(%rbp), %rdx
	movq	%rdx, 24(%rax)
	movq	NIL(%rip), %rax
	cmpq	%rax, -24(%rbp)
	jne	.L5
	movq	-8(%rbp), %rax
	movq	%rax, B(%rip)
	jmp	.L8
.L5:
	movq	-8(%rbp), %rax
	movl	(%rax), %edx
	movq	-24(%rbp), %rax
	movl	(%rax), %eax
	cmpl	%eax, %edx
	jge	.L7
	movq	-24(%rbp), %rax
	movq	-8(%rbp), %rdx
	movq	%rdx, 16(%rax)
	jmp	.L8
.L7:
	movq	-24(%rbp), %rax
	movq	-8(%rbp), %rdx
	movq	%rdx, 8(%rax)
.L8:
	nop
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	insert, .-insert
	.section	.rodata
.LC0:
	.string	" %d"
	.text
	.globl	inorder
	.type	inorder, @function
inorder:
.LFB7:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$16, %rsp
	movq	%rdi, -8(%rbp)
	movq	NIL(%rip), %rax
	cmpq	%rax, -8(%rbp)
	je	.L12
	movq	-8(%rbp), %rax
	movq	16(%rax), %rax
	movq	%rax, %rdi
	call	inorder
	movq	-8(%rbp), %rax
	movl	(%rax), %eax
	movl	%eax, %esi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movq	-8(%rbp), %rax
	movq	8(%rax), %rax
	movq	%rax, %rdi
	call	inorder
	jmp	.L9
.L12:
	nop
.L9:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.size	inorder, .-inorder
	.globl	preorder
	.type	preorder, @function
preorder:
.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	NIL(%rip), %rax
	cmpq	%rax, -8(%rbp)
	je	.L16
	movq	-8(%rbp), %rax
	movl	(%rax), %eax
	movl	%eax, %esi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movq	-8(%rbp), %rax
	movq	16(%rax), %rax
	movq	%rax, %rdi
	call	preorder
	movq	-8(%rbp), %rax
	movq	8(%rax), %rax
	movq	%rax, %rdi
	call	preorder
	jmp	.L13
.L16:
	nop
.L13:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE8:
	.size	preorder, .-preorder
	.section	.rodata
.LC1:
	.string	"%d"
.LC2:
	.string	"%s"
	.text
	.globl	main
	.type	main, @function
main:
.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	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-28(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -20(%rbp)
	jmp	.L18
.L21:
	leaq	-16(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movzbl	-16(%rbp), %eax
	cmpb	$105, %al
	jne	.L19
	leaq	-24(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-24(%rbp), %eax
	movl	%eax, %edi
	call	insert
	jmp	.L20
.L19:
	movzbl	-16(%rbp), %eax
	cmpb	$112, %al
	jne	.L20
	movq	B(%rip), %rax
	movq	%rax, %rdi
	call	inorder
	movl	$10, %edi
	call	putchar@PLT
	movq	B(%rip), %rax
	movq	%rax, %rdi
	call	preorder
	movl	$10, %edi
	call	putchar@PLT
.L20:
	addl	$1, -20(%rbp)
.L18:
	movl	-28(%rbp), %eax
	cmpl	%eax, -20(%rbp)
	jl	.L21
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L23
	call	__stack_chk_fail@PLT
.L23:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE9:
	.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:
