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<string.h>
void North(int *a,int *b,int *e,int *f){
  int x;
  x = *a;
  *a = *b;
  *b = *f;
  *f = *e;
  *e = x;
}

void East(int *a,int *c,int *d,int *f){
  int x;
  x = *a;
  *a = *d;
  *d = *f;
  *f = *c;
  *c = x;
}

void West(int *a,int *c,int *d,int *f){
  int x;
  x = *a;
  *a = *c;
  *c = *f;
  *f = *d;
  *d = x;
}

void South(int *a,int *b,int *e,int *f){
  int x;
  x = *a;
  *a = *e;
  *e = *f;
  *f = *b;
  *b = x;
}

void Right(int *b,int *c,int *d,int *e){
  int x;
  x = *b;
  *b = *c;
  *c = *e;
  *e = *d;
  *d = x;
}

void Left(int *b,int *c,int *d,int *e){
  int x;
  x = *b;
  *b = *d;
  *d = *e;
  *e = *c;
  *c =x;
}



int main(void){
  int n,i,a[7],sum;
  char text[10];
  while(1){
    for(i=1;i<7;i++){
      a[i] = i;
    }
    sum = 1;
    scanf("%d",&n);
    if(n==0)return(0);
    for(i=0;i<n;i++){
      scanf("%s",text);
      if(strcmp(text,"North")==0){
	North(&a[1],&a[2],&a[5],&a[6]);
	sum += a[1];
      }
      else if(strcmp(text,"East")==0){
	East(&a[1],&a[3],&a[4],&a[6]);
	sum += a[1];
      }
      else if(strcmp(text,"West")==0){
	West(&a[1],&a[3],&a[4],&a[6]);
	sum += a[1];
      }
      else if(strcmp(text,"South")==0){
	South(&a[1],&a[2],&a[5],&a[6]);
	sum += a[1];
      }
      else if(strcmp(text,"Right")==0){
	Right(&a[2],&a[3],&a[4],&a[5]);
	sum += a[1];
      }
      else if(strcmp(text,"Left")==0){
	Left(&a[2],&a[3],&a[4],&a[5]);
	sum += a[1];
      }
    }
    printf("%d\n",sum);
  }
  
  return(0);
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	North
	.type	North, @function
North:
.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)
	movq	%rsi, -32(%rbp)
	movq	%rdx, -40(%rbp)
	movq	%rcx, -48(%rbp)
	movq	-24(%rbp), %rax
	movl	(%rax), %eax
	movl	%eax, -4(%rbp)
	movq	-32(%rbp), %rax
	movl	(%rax), %edx
	movq	-24(%rbp), %rax
	movl	%edx, (%rax)
	movq	-48(%rbp), %rax
	movl	(%rax), %edx
	movq	-32(%rbp), %rax
	movl	%edx, (%rax)
	movq	-40(%rbp), %rax
	movl	(%rax), %edx
	movq	-48(%rbp), %rax
	movl	%edx, (%rax)
	movq	-40(%rbp), %rax
	movl	-4(%rbp), %edx
	movl	%edx, (%rax)
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	North, .-North
	.globl	East
	.type	East, @function
East:
.LFB1:
	.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)
	movq	%rsi, -32(%rbp)
	movq	%rdx, -40(%rbp)
	movq	%rcx, -48(%rbp)
	movq	-24(%rbp), %rax
	movl	(%rax), %eax
	movl	%eax, -4(%rbp)
	movq	-40(%rbp), %rax
	movl	(%rax), %edx
	movq	-24(%rbp), %rax
	movl	%edx, (%rax)
	movq	-48(%rbp), %rax
	movl	(%rax), %edx
	movq	-40(%rbp), %rax
	movl	%edx, (%rax)
	movq	-32(%rbp), %rax
	movl	(%rax), %edx
	movq	-48(%rbp), %rax
	movl	%edx, (%rax)
	movq	-32(%rbp), %rax
	movl	-4(%rbp), %edx
	movl	%edx, (%rax)
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.size	East, .-East
	.globl	West
	.type	West, @function
West:
.LFB2:
	.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)
	movq	%rsi, -32(%rbp)
	movq	%rdx, -40(%rbp)
	movq	%rcx, -48(%rbp)
	movq	-24(%rbp), %rax
	movl	(%rax), %eax
	movl	%eax, -4(%rbp)
	movq	-32(%rbp), %rax
	movl	(%rax), %edx
	movq	-24(%rbp), %rax
	movl	%edx, (%rax)
	movq	-48(%rbp), %rax
	movl	(%rax), %edx
	movq	-32(%rbp), %rax
	movl	%edx, (%rax)
	movq	-40(%rbp), %rax
	movl	(%rax), %edx
	movq	-48(%rbp), %rax
	movl	%edx, (%rax)
	movq	-40(%rbp), %rax
	movl	-4(%rbp), %edx
	movl	%edx, (%rax)
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE2:
	.size	West, .-West
	.globl	South
	.type	South, @function
South:
.LFB3:
	.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)
	movq	%rsi, -32(%rbp)
	movq	%rdx, -40(%rbp)
	movq	%rcx, -48(%rbp)
	movq	-24(%rbp), %rax
	movl	(%rax), %eax
	movl	%eax, -4(%rbp)
	movq	-40(%rbp), %rax
	movl	(%rax), %edx
	movq	-24(%rbp), %rax
	movl	%edx, (%rax)
	movq	-48(%rbp), %rax
	movl	(%rax), %edx
	movq	-40(%rbp), %rax
	movl	%edx, (%rax)
	movq	-32(%rbp), %rax
	movl	(%rax), %edx
	movq	-48(%rbp), %rax
	movl	%edx, (%rax)
	movq	-32(%rbp), %rax
	movl	-4(%rbp), %edx
	movl	%edx, (%rax)
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE3:
	.size	South, .-South
	.globl	Right
	.type	Right, @function
Right:
.LFB4:
	.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)
	movq	%rsi, -32(%rbp)
	movq	%rdx, -40(%rbp)
	movq	%rcx, -48(%rbp)
	movq	-24(%rbp), %rax
	movl	(%rax), %eax
	movl	%eax, -4(%rbp)
	movq	-32(%rbp), %rax
	movl	(%rax), %edx
	movq	-24(%rbp), %rax
	movl	%edx, (%rax)
	movq	-48(%rbp), %rax
	movl	(%rax), %edx
	movq	-32(%rbp), %rax
	movl	%edx, (%rax)
	movq	-40(%rbp), %rax
	movl	(%rax), %edx
	movq	-48(%rbp), %rax
	movl	%edx, (%rax)
	movq	-40(%rbp), %rax
	movl	-4(%rbp), %edx
	movl	%edx, (%rax)
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE4:
	.size	Right, .-Right
	.globl	Left
	.type	Left, @function
Left:
.LFB5:
	.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)
	movq	%rsi, -32(%rbp)
	movq	%rdx, -40(%rbp)
	movq	%rcx, -48(%rbp)
	movq	-24(%rbp), %rax
	movl	(%rax), %eax
	movl	%eax, -4(%rbp)
	movq	-40(%rbp), %rax
	movl	(%rax), %edx
	movq	-24(%rbp), %rax
	movl	%edx, (%rax)
	movq	-48(%rbp), %rax
	movl	(%rax), %edx
	movq	-40(%rbp), %rax
	movl	%edx, (%rax)
	movq	-32(%rbp), %rax
	movl	(%rax), %edx
	movq	-48(%rbp), %rax
	movl	%edx, (%rax)
	movq	-32(%rbp), %rax
	movl	-4(%rbp), %edx
	movl	%edx, (%rax)
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE5:
	.size	Left, .-Left
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%s"
.LC2:
	.string	"North"
.LC3:
	.string	"East"
.LC4:
	.string	"West"
.LC5:
	.string	"South"
.LC6:
	.string	"Right"
.LC7:
	.string	"Left"
.LC8:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB6:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$64, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
.L20:
	movl	$1, -56(%rbp)
	jmp	.L8
.L9:
	movl	-56(%rbp), %eax
	cltq
	movl	-56(%rbp), %edx
	movl	%edx, -48(%rbp,%rax,4)
	addl	$1, -56(%rbp)
.L8:
	cmpl	$6, -56(%rbp)
	jle	.L9
	movl	$1, -52(%rbp)
	leaq	-60(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-60(%rbp), %eax
	testl	%eax, %eax
	jne	.L10
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L21
	jmp	.L22
.L10:
	movl	$0, -56(%rbp)
	jmp	.L12
.L19:
	leaq	-18(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	leaq	-18(%rbp), %rax
	leaq	.LC2(%rip), %rdx
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	strcmp@PLT
	testl	%eax, %eax
	jne	.L13
	leaq	-48(%rbp), %rax
	leaq	24(%rax), %rcx
	leaq	-48(%rbp), %rax
	leaq	20(%rax), %rdx
	leaq	-48(%rbp), %rax
	leaq	8(%rax), %rsi
	leaq	-48(%rbp), %rax
	addq	$4, %rax
	movq	%rax, %rdi
	call	North
	movl	-44(%rbp), %eax
	addl	%eax, -52(%rbp)
	jmp	.L14
.L13:
	leaq	-18(%rbp), %rax
	leaq	.LC3(%rip), %rdx
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	strcmp@PLT
	testl	%eax, %eax
	jne	.L15
	leaq	-48(%rbp), %rax
	leaq	24(%rax), %rcx
	leaq	-48(%rbp), %rax
	leaq	16(%rax), %rdx
	leaq	-48(%rbp), %rax
	leaq	12(%rax), %rsi
	leaq	-48(%rbp), %rax
	addq	$4, %rax
	movq	%rax, %rdi
	call	East
	movl	-44(%rbp), %eax
	addl	%eax, -52(%rbp)
	jmp	.L14
.L15:
	leaq	-18(%rbp), %rax
	leaq	.LC4(%rip), %rdx
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	strcmp@PLT
	testl	%eax, %eax
	jne	.L16
	leaq	-48(%rbp), %rax
	leaq	24(%rax), %rcx
	leaq	-48(%rbp), %rax
	leaq	16(%rax), %rdx
	leaq	-48(%rbp), %rax
	leaq	12(%rax), %rsi
	leaq	-48(%rbp), %rax
	addq	$4, %rax
	movq	%rax, %rdi
	call	West
	movl	-44(%rbp), %eax
	addl	%eax, -52(%rbp)
	jmp	.L14
.L16:
	leaq	-18(%rbp), %rax
	leaq	.LC5(%rip), %rdx
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	strcmp@PLT
	testl	%eax, %eax
	jne	.L17
	leaq	-48(%rbp), %rax
	leaq	24(%rax), %rcx
	leaq	-48(%rbp), %rax
	leaq	20(%rax), %rdx
	leaq	-48(%rbp), %rax
	leaq	8(%rax), %rsi
	leaq	-48(%rbp), %rax
	addq	$4, %rax
	movq	%rax, %rdi
	call	South
	movl	-44(%rbp), %eax
	addl	%eax, -52(%rbp)
	jmp	.L14
.L17:
	leaq	-18(%rbp), %rax
	leaq	.LC6(%rip), %rdx
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	strcmp@PLT
	testl	%eax, %eax
	jne	.L18
	leaq	-48(%rbp), %rax
	leaq	20(%rax), %rcx
	leaq	-48(%rbp), %rax
	leaq	16(%rax), %rdx
	leaq	-48(%rbp), %rax
	leaq	12(%rax), %rsi
	leaq	-48(%rbp), %rax
	addq	$8, %rax
	movq	%rax, %rdi
	call	Right
	movl	-44(%rbp), %eax
	addl	%eax, -52(%rbp)
	jmp	.L14
.L18:
	leaq	-18(%rbp), %rax
	leaq	.LC7(%rip), %rdx
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	strcmp@PLT
	testl	%eax, %eax
	jne	.L14
	leaq	-48(%rbp), %rax
	leaq	20(%rax), %rcx
	leaq	-48(%rbp), %rax
	leaq	16(%rax), %rdx
	leaq	-48(%rbp), %rax
	leaq	12(%rax), %rsi
	leaq	-48(%rbp), %rax
	addq	$8, %rax
	movq	%rax, %rdi
	call	Left
	movl	-44(%rbp), %eax
	addl	%eax, -52(%rbp)
.L14:
	addl	$1, -56(%rbp)
.L12:
	movl	-60(%rbp), %eax
	cmpl	%eax, -56(%rbp)
	jl	.L19
	movl	-52(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC8(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L20
.L22:
	call	__stack_chk_fail@PLT
.L21:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.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	North
	.type	North, @function
North:
.LFB35:
	.cfi_startproc
	endbr64
	movl	(%rsi), %r8d
	movl	(%rdi), %eax
	movl	%r8d, (%rdi)
	movl	(%rcx), %edi
	movl	%edi, (%rsi)
	movl	(%rdx), %esi
	movl	%esi, (%rcx)
	movl	%eax, (%rdx)
	ret
	.cfi_endproc
.LFE35:
	.size	North, .-North
	.p2align 4
	.globl	East
	.type	East, @function
East:
.LFB36:
	.cfi_startproc
	endbr64
	movl	(%rdx), %r8d
	movl	(%rdi), %eax
	movl	%r8d, (%rdi)
	movl	(%rcx), %edi
	movl	%edi, (%rdx)
	movl	(%rsi), %edx
	movl	%edx, (%rcx)
	movl	%eax, (%rsi)
	ret
	.cfi_endproc
.LFE36:
	.size	East, .-East
	.p2align 4
	.globl	West
	.type	West, @function
West:
.LFB43:
	.cfi_startproc
	endbr64
	movl	(%rsi), %r8d
	movl	(%rdi), %eax
	movl	%r8d, (%rdi)
	movl	(%rcx), %edi
	movl	%edi, (%rsi)
	movl	(%rdx), %esi
	movl	%esi, (%rcx)
	movl	%eax, (%rdx)
	ret
	.cfi_endproc
.LFE43:
	.size	West, .-West
	.p2align 4
	.globl	South
	.type	South, @function
South:
.LFB47:
	.cfi_startproc
	endbr64
	movl	(%rdx), %r8d
	movl	(%rdi), %eax
	movl	%r8d, (%rdi)
	movl	(%rcx), %edi
	movl	%edi, (%rdx)
	movl	(%rsi), %edx
	movl	%edx, (%rcx)
	movl	%eax, (%rsi)
	ret
	.cfi_endproc
.LFE47:
	.size	South, .-South
	.p2align 4
	.globl	Right
	.type	Right, @function
Right:
.LFB45:
	.cfi_startproc
	endbr64
	movl	(%rsi), %r8d
	movl	(%rdi), %eax
	movl	%r8d, (%rdi)
	movl	(%rcx), %edi
	movl	%edi, (%rsi)
	movl	(%rdx), %esi
	movl	%esi, (%rcx)
	movl	%eax, (%rdx)
	ret
	.cfi_endproc
.LFE45:
	.size	Right, .-Right
	.p2align 4
	.globl	Left
	.type	Left, @function
Left:
.LFB49:
	.cfi_startproc
	endbr64
	movl	(%rdx), %r8d
	movl	(%rdi), %eax
	movl	%r8d, (%rdi)
	movl	(%rcx), %edi
	movl	%edi, (%rdx)
	movl	(%rsi), %edx
	movl	%edx, (%rcx)
	movl	%eax, (%rsi)
	ret
	.cfi_endproc
.LFE49:
	.size	Left, .-Left
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d"
.LC1:
	.string	"%s"
.LC2:
	.string	"North"
.LC3:
	.string	"East"
.LC4:
	.string	"West"
.LC5:
	.string	"South"
.LC6:
	.string	"Right"
.LC7:
	.string	"Left"
.LC8:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB41:
	.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
	leaq	.LC1(%rip), %rbx
	subq	$72, %rsp
	.cfi_def_cfa_offset 128
	movq	%fs:40, %rax
	movq	%rax, 56(%rsp)
	xorl	%eax, %eax
	leaq	40(%rsp), %rax
	movq	%rax, 24(%rsp)
	.p2align 4,,10
	.p2align 3
.L30:
	movq	24(%rsp), %rsi
	leaq	.LC0(%rip), %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	40(%rsp), %eax
	testl	%eax, %eax
	je	.L9
	movl	$1, %r12d
	jle	.L11
	leaq	46(%rsp), %r15
	xorl	%r14d, %r14d
	movl	$5, 12(%rsp)
	movl	$6, %r13d
	movq	%r15, %rax
	movl	$1, %ebp
	movl	%r14d, %r15d
	movl	$4, 20(%rsp)
	movl	$3, 16(%rsp)
	movl	$1, %r12d
	movq	%rax, %r14
	movl	$2, 8(%rsp)
	jmp	.L10
	.p2align 4,,10
	.p2align 3
.L12:
	cmpl	$1953718597, (%r14)
	je	.L36
.L16:
	cmpl	$1953719639, (%r14)
	je	.L37
.L19:
	cmpl	$1953853267, (%r14)
	je	.L38
.L22:
	cmpl	$1751607634, (%r14)
	je	.L39
.L25:
	cmpl	$1952867660, (%r14)
	je	.L40
	.p2align 4,,10
	.p2align 3
.L15:
	addl	$1, %r15d
	cmpl	%r15d, 40(%rsp)
	jle	.L11
.L10:
	xorl	%eax, %eax
	movq	%r14, %rsi
	movq	%rbx, %rdi
	call	__isoc99_scanf@PLT
	cmpl	$1953656654, (%r14)
	jne	.L12
	cmpw	$104, 4(%r14)
	jne	.L12
	movl	8(%rsp), %ecx
	movl	%ebp, %eax
	movl	%r13d, 8(%rsp)
	addl	$1, %r15d
	movl	12(%rsp), %r13d
	movl	%eax, 12(%rsp)
	addl	%ecx, %r12d
	movl	%ecx, %ebp
	cmpl	%r15d, 40(%rsp)
	jg	.L10
	.p2align 4,,10
	.p2align 3
.L11:
	movl	%r12d, %edx
	leaq	.LC8(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L30
	.p2align 4,,10
	.p2align 3
.L36:
	cmpb	$0, 4(%r14)
	jne	.L16
	movl	20(%rsp), %edx
	movl	%ebp, %eax
	movl	%r13d, 20(%rsp)
	movl	16(%rsp), %r13d
	movl	%eax, 16(%rsp)
	addl	%edx, %r12d
	movl	%edx, %ebp
	jmp	.L15
	.p2align 4,,10
	.p2align 3
.L37:
	cmpb	$0, 4(%r14)
	jne	.L19
	movl	16(%rsp), %ecx
	movl	%ebp, %eax
	movl	%r13d, 16(%rsp)
	movl	20(%rsp), %r13d
	movl	%eax, 20(%rsp)
	addl	%ecx, %r12d
	movl	%ecx, %ebp
	jmp	.L15
	.p2align 4,,10
	.p2align 3
.L38:
	cmpw	$104, 4(%r14)
	jne	.L22
	movl	12(%rsp), %edx
	movl	%ebp, %eax
	movl	%r13d, 12(%rsp)
	movl	8(%rsp), %r13d
	movl	%eax, 8(%rsp)
	addl	%edx, %r12d
	movl	%edx, %ebp
	jmp	.L15
	.p2align 4,,10
	.p2align 3
.L39:
	cmpw	$116, 4(%r14)
	jne	.L25
	movl	16(%rsp), %edx
	movl	8(%rsp), %eax
	addl	%ebp, %r12d
	movl	%edx, 8(%rsp)
	movl	12(%rsp), %edx
	movl	%edx, 16(%rsp)
	movl	20(%rsp), %edx
	movl	%eax, 20(%rsp)
	movl	%edx, 12(%rsp)
	jmp	.L15
	.p2align 4,,10
	.p2align 3
.L9:
	movq	56(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L41
	addq	$72, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 56
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L40:
	.cfi_restore_state
	cmpb	$0, 4(%r14)
	jne	.L15
	movl	20(%rsp), %edx
	movl	8(%rsp), %eax
	addl	%ebp, %r12d
	movl	16(%rsp), %ecx
	movl	%edx, 8(%rsp)
	movl	12(%rsp), %edx
	movl	%eax, 16(%rsp)
	movl	%edx, 20(%rsp)
	movl	%ecx, 12(%rsp)
	jmp	.L15
.L41:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE41:
	.size	main, .-main
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:

rule
	.file	"temp.c"
	.text
	.p2align 4
	.globl	North
	.type	North, @function
North:
.LFB35:
	.cfi_startproc
	endbr64
	movl	(%rsi), %r8d
	movl	(%rdi), %eax
	movl	%r8d, (%rdi)
	movl	(%rcx), %edi
	movl	%edi, (%rsi)
	movl	(%rdx), %esi
	movl	%esi, (%rcx)
	movl	%eax, (%rdx)
	ret
	.cfi_endproc
.LFE35:
	.size	North, .-North
	.p2align 4
	.globl	East
	.type	East, @function
East:
.LFB36:
	.cfi_startproc
	endbr64
	movl	(%rdx), %r8d
	movl	(%rdi), %eax
	movl	%r8d, (%rdi)
	movl	(%rcx), %edi
	movl	%edi, (%rdx)
	movl	(%rsi), %edx
	movl	%edx, (%rcx)
	movl	%eax, (%rsi)
	ret
	.cfi_endproc
.LFE36:
	.size	East, .-East
	.p2align 4
	.globl	West
	.type	West, @function
West:
.LFB43:
	.cfi_startproc
	endbr64
	movl	(%rsi), %r8d
	movl	(%rdi), %eax
	movl	%r8d, (%rdi)
	movl	(%rcx), %edi
	movl	%edi, (%rsi)
	movl	(%rdx), %esi
	movl	%esi, (%rcx)
	movl	%eax, (%rdx)
	ret
	.cfi_endproc
.LFE43:
	.size	West, .-West
	.p2align 4
	.globl	South
	.type	South, @function
South:
.LFB47:
	.cfi_startproc
	endbr64
	movl	(%rdx), %r8d
	movl	(%rdi), %eax
	movl	%r8d, (%rdi)
	movl	(%rcx), %edi
	movl	%edi, (%rdx)
	movl	(%rsi), %edx
	movl	%edx, (%rcx)
	movl	%eax, (%rsi)
	ret
	.cfi_endproc
.LFE47:
	.size	South, .-South
	.p2align 4
	.globl	Right
	.type	Right, @function
Right:
.LFB45:
	.cfi_startproc
	endbr64
	movl	(%rsi), %r8d
	movl	(%rdi), %eax
	movl	%r8d, (%rdi)
	movl	(%rcx), %edi
	movl	%edi, (%rsi)
	movl	(%rdx), %esi
	movl	%esi, (%rcx)
	movl	%eax, (%rdx)
	ret
	.cfi_endproc
.LFE45:
	.size	Right, .-Right
	.p2align 4
	.globl	Left
	.type	Left, @function
Left:
.LFB49:
	.cfi_startproc
	endbr64
	movl	(%rdx), %r8d
	movl	(%rdi), %eax
	movl	%r8d, (%rdi)
	movl	(%rcx), %edi
	movl	%edi, (%rdx)
	movl	(%rsi), %edx
	movl	%edx, (%rcx)
	movl	%eax, (%rsi)
	ret
	.cfi_endproc
.LFE49:
	.size	Left, .-Left
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d"
.LC1:
	.string	"%s"
.LC2:
	.string	"North"
.LC3:
	.string	"East"
.LC4:
	.string	"West"
.LC5:
	.string	"South"
.LC6:
	.string	"Right"
.LC7:
	.string	"Left"
.LC8:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB41:
	.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
	leaq	.LC1(%rip), %rbx
	subq	$72, %rsp
	.cfi_def_cfa_offset 128
	movq	%fs:40, %rax
	movq	%rax, 56(%rsp)
	xorl	%eax, %eax
	leaq	40(%rsp), %rax
	movq	%rax, 24(%rsp)
	.p2align 4,,10
	.p2align 3
.L30:
	movq	24(%rsp), %rsi
	leaq	.LC0(%rip), %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	40(%rsp), %eax
	testl	%eax, %eax
	je	.L9
	movl	$1, %r12d
	jle	.L11
	leaq	46(%rsp), %r15
	xorl	%r14d, %r14d
	movl	$5, 12(%rsp)
	movl	$6, %r13d
	movq	%r15, %rax
	movl	$1, %ebp
	movl	%r14d, %r15d
	movl	$4, 20(%rsp)
	movl	$3, 16(%rsp)
	movl	$1, %r12d
	movq	%rax, %r14
	movl	$2, 8(%rsp)
	jmp	.L10
	.p2align 4,,10
	.p2align 3
.L12:
	cmpl	$1953718597, (%r14)
	je	.L36
.L16:
	cmpl	$1953719639, (%r14)
	je	.L37
.L19:
	cmpl	$1953853267, (%r14)
	je	.L38
.L22:
	cmpl	$1751607634, (%r14)
	je	.L39
.L25:
	cmpl	$1952867660, (%r14)
	je	.L40
	.p2align 4,,10
	.p2align 3
.L15:
	addl	$1, %r15d
	cmpl	%r15d, 40(%rsp)
	jle	.L11
.L10:
	xorl	%eax, %eax
	movq	%r14, %rsi
	movq	%rbx, %rdi
	call	__isoc99_scanf@PLT
	cmpl	$1953656654, (%r14)
	jne	.L12
	cmpw	$104, 4(%r14)
	jne	.L12
	movl	8(%rsp), %ecx
	movl	%ebp, %eax
	movl	%r13d, 8(%rsp)
	addl	$1, %r15d
	movl	12(%rsp), %r13d
	movl	%eax, 12(%rsp)
	addl	%ecx, %r12d
	movl	%ecx, %ebp
	cmpl	%r15d, 40(%rsp)
	jg	.L10
	.p2align 4,,10
	.p2align 3
.L11:
	movl	%r12d, %edx
	leaq	.LC8(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L30
	.p2align 4,,10
	.p2align 3
.L36:
	cmpb	$0, 4(%r14)
	jne	.L16
	movl	20(%rsp), %edx
	movl	%ebp, %eax
	movl	%r13d, 20(%rsp)
	movl	16(%rsp), %r13d
	movl	%eax, 16(%rsp)
	addl	%edx, %r12d
	movl	%edx, %ebp
	jmp	.L15
	.p2align 4,,10
	.p2align 3
.L37:
	cmpb	$0, 4(%r14)
	jne	.L19
	movl	16(%rsp), %ecx
	movl	%ebp, %eax
	movl	%r13d, 16(%rsp)
	movl	20(%rsp), %r13d
	movl	%eax, 20(%rsp)
	addl	%ecx, %r12d
	movl	%ecx, %ebp
	jmp	.L15
	.p2align 4,,10
	.p2align 3
.L38:
	cmpw	$104, 4(%r14)
	jne	.L22
	movl	12(%rsp), %edx
	movl	%ebp, %eax
	movl	%r13d, 12(%rsp)
	movl	8(%rsp), %r13d
	movl	%eax, 8(%rsp)
	addl	%edx, %r12d
	movl	%edx, %ebp
	jmp	.L15
	.p2align 4,,10
	.p2align 3
.L39:
	cmpw	$116, 4(%r14)
	jne	.L25
	movl	16(%rsp), %edx
	movl	8(%rsp), %eax
	addl	%ebp, %r12d
	movl	%edx, 8(%rsp)
	movl	12(%rsp), %edx
	movl	%edx, 16(%rsp)
	movl	20(%rsp), %edx
	movl	%eax, 20(%rsp)
	movl	%edx, 12(%rsp)
	jmp	.L15
	.p2align 4,,10
	.p2align 3
.L9:
	movq	56(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L41
	addq	$72, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 56
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L40:
	.cfi_restore_state
	cmpb	$0, 4(%r14)
	jne	.L15
	movl	20(%rsp), %edx
	movl	8(%rsp), %eax
	addl	%ebp, %r12d
	movl	16(%rsp), %ecx
	movl	%edx, 8(%rsp)
	movl	12(%rsp), %edx
	movl	%eax, 16(%rsp)
	movl	%edx, 20(%rsp)
	movl	%ecx, 12(%rsp)
	jmp	.L15
.L41:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE41:
	.size	main, .-main
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:

#include<stdio.h>
#include<string.h>
void North(int *a,int *b,int *e,int *f){
  int x;
  x = *a;
  *a = *b;
  *b = *f;
  *f = *e;
  *e = x;
}

void East(int *a,int *c,int *d,int *f){
  int x;
  x = *a;
  *a = *d;
  *d = *f;
  *f = *c;
  *c = x;
}

void West(int *a,int *c,int *d,int *f){
  int x;
  x = *a;
  *a = *c;
  *c = *f;
  *f = *d;
  *d = x;
}

void South(int *a,int *b,int *e,int *f){
  int x;
  x = *a;
  *a = *e;
  *e = *f;
  *f = *b;
  *b = x;
}

void Right(int *b,int *c,int *d,int *e){
  int x;
  x = *b;
  *b = *c;
  *c = *e;
  *e = *d;
  *d = x;
}

void Left(int *b,int *c,int *d,int *e){
  int x;
  x = *b;
  *b = *d;
  *d = *e;
  *e = *c;
  *c =x;
}



int main(void){
  int n,i,a[7],sum;
  char text[10];
  while(1){
    for(i=1;i<7;i++){
      a[i] = i;
    }
    sum = 1;
    scanf("%d",&n);
    if(n==0)return(0);
    for(i=0;i<n;i++){
      scanf("%s",text);
      if(strcmp(text,"North")==0){
	North(&a[1],&a[2],&a[5],&a[6]);
	sum += a[1];
      }
      else if(strcmp(text,"East")==0){
	East(&a[1],&a[3],&a[4],&a[6]);
	sum += a[1];
      }
      else if(strcmp(text,"West")==0){
	West(&a[1],&a[3],&a[4],&a[6]);
	sum += a[1];
      }
      else if(strcmp(text,"South")==0){
	South(&a[1],&a[2],&a[5],&a[6]);
	sum += a[1];
      }
      else if(strcmp(text,"Right")==0){
	Right(&a[2],&a[3],&a[4],&a[5]);
	sum += a[1];
      }
      else if(strcmp(text,"Left")==0){
	Left(&a[2],&a[3],&a[4],&a[5]);
	sum += a[1];
      }
    }
    printf("%d\n",sum);
  }
  
  return(0);
}
5
North
North
East
South
West
8
West
North
Left
South
Right
North
Left
East
0
 5
North
North
East
South
West
8
West
North
Left
South
Right
North
Left
East
0

21
34
 21
34

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<string.h>
void North(int *a,int *b,int *e,int *f){
  int x;
  x = *a;
  *a = *b;
  *b = *f;
  *f = *e;
  *e = x;
}

void East(int *a,int *c,int *d,int *f){
  int x;
  x = *a;
  *a = *d;
  *d = *f;
  *f = *c;
  *c = x;
}

void West(int *a,int *c,int *d,int *f){
  int x;
  x = *a;
  *a = *c;
  *c = *f;
  *f = *d;
  *d = x;
}

void South(int *a,int *b,int *e,int *f){
  int x;
  x = *a;
  *a = *e;
  *e = *f;
  *f = *b;
  *b = x;
}

void Right(int *b,int *c,int *d,int *e){
  int x;
  x = *b;
  *b = *c;
  *c = *e;
  *e = *d;
  *d = x;
}

void Left(int *b,int *c,int *d,int *e){
  int x;
  x = *b;
  *b = *d;
  *d = *e;
  *e = *c;
  *c =x;
}



int main(void){
  int n,i,a[7],sum;
  char text[10];
  while(1){
    for(i=1;i<7;i++){
      a[i] = i;
    }
    sum = 1;
    scanf("%d",&n);
    if(n==0)return(0);
    for(i=0;i<n;i++){
      scanf("%s",text);
      if(strcmp(text,"North")==0){
	North(&a[1],&a[2],&a[5],&a[6]);
	sum += a[1];
      }
      else if(strcmp(text,"East")==0){
	East(&a[1],&a[3],&a[4],&a[6]);
	sum += a[1];
      }
      else if(strcmp(text,"West")==0){
	West(&a[1],&a[3],&a[4],&a[6]);
	sum += a[1];
      }
      else if(strcmp(text,"South")==0){
	South(&a[1],&a[2],&a[5],&a[6]);
	sum += a[1];
      }
      else if(strcmp(text,"Right")==0){
	Right(&a[2],&a[3],&a[4],&a[5]);
	sum += a[1];
      }
      else if(strcmp(text,"Left")==0){
	Left(&a[2],&a[3],&a[4],&a[5]);
	sum += a[1];
      }
    }
    printf("%d\n",sum);
  }
  
  return(0);
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	North
	.type	North, @function
North:
.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)
	movq	%rsi, -32(%rbp)
	movq	%rdx, -40(%rbp)
	movq	%rcx, -48(%rbp)
	movq	-24(%rbp), %rax
	movl	(%rax), %eax
	movl	%eax, -4(%rbp)
	movq	-32(%rbp), %rax
	movl	(%rax), %edx
	movq	-24(%rbp), %rax
	movl	%edx, (%rax)
	movq	-48(%rbp), %rax
	movl	(%rax), %edx
	movq	-32(%rbp), %rax
	movl	%edx, (%rax)
	movq	-40(%rbp), %rax
	movl	(%rax), %edx
	movq	-48(%rbp), %rax
	movl	%edx, (%rax)
	movq	-40(%rbp), %rax
	movl	-4(%rbp), %edx
	movl	%edx, (%rax)
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	North, .-North
	.globl	East
	.type	East, @function
East:
.LFB1:
	.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)
	movq	%rsi, -32(%rbp)
	movq	%rdx, -40(%rbp)
	movq	%rcx, -48(%rbp)
	movq	-24(%rbp), %rax
	movl	(%rax), %eax
	movl	%eax, -4(%rbp)
	movq	-40(%rbp), %rax
	movl	(%rax), %edx
	movq	-24(%rbp), %rax
	movl	%edx, (%rax)
	movq	-48(%rbp), %rax
	movl	(%rax), %edx
	movq	-40(%rbp), %rax
	movl	%edx, (%rax)
	movq	-32(%rbp), %rax
	movl	(%rax), %edx
	movq	-48(%rbp), %rax
	movl	%edx, (%rax)
	movq	-32(%rbp), %rax
	movl	-4(%rbp), %edx
	movl	%edx, (%rax)
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.size	East, .-East
	.globl	West
	.type	West, @function
West:
.LFB2:
	.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)
	movq	%rsi, -32(%rbp)
	movq	%rdx, -40(%rbp)
	movq	%rcx, -48(%rbp)
	movq	-24(%rbp), %rax
	movl	(%rax), %eax
	movl	%eax, -4(%rbp)
	movq	-32(%rbp), %rax
	movl	(%rax), %edx
	movq	-24(%rbp), %rax
	movl	%edx, (%rax)
	movq	-48(%rbp), %rax
	movl	(%rax), %edx
	movq	-32(%rbp), %rax
	movl	%edx, (%rax)
	movq	-40(%rbp), %rax
	movl	(%rax), %edx
	movq	-48(%rbp), %rax
	movl	%edx, (%rax)
	movq	-40(%rbp), %rax
	movl	-4(%rbp), %edx
	movl	%edx, (%rax)
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE2:
	.size	West, .-West
	.globl	South
	.type	South, @function
South:
.LFB3:
	.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)
	movq	%rsi, -32(%rbp)
	movq	%rdx, -40(%rbp)
	movq	%rcx, -48(%rbp)
	movq	-24(%rbp), %rax
	movl	(%rax), %eax
	movl	%eax, -4(%rbp)
	movq	-40(%rbp), %rax
	movl	(%rax), %edx
	movq	-24(%rbp), %rax
	movl	%edx, (%rax)
	movq	-48(%rbp), %rax
	movl	(%rax), %edx
	movq	-40(%rbp), %rax
	movl	%edx, (%rax)
	movq	-32(%rbp), %rax
	movl	(%rax), %edx
	movq	-48(%rbp), %rax
	movl	%edx, (%rax)
	movq	-32(%rbp), %rax
	movl	-4(%rbp), %edx
	movl	%edx, (%rax)
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE3:
	.size	South, .-South
	.globl	Right
	.type	Right, @function
Right:
.LFB4:
	.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)
	movq	%rsi, -32(%rbp)
	movq	%rdx, -40(%rbp)
	movq	%rcx, -48(%rbp)
	movq	-24(%rbp), %rax
	movl	(%rax), %eax
	movl	%eax, -4(%rbp)
	movq	-32(%rbp), %rax
	movl	(%rax), %edx
	movq	-24(%rbp), %rax
	movl	%edx, (%rax)
	movq	-48(%rbp), %rax
	movl	(%rax), %edx
	movq	-32(%rbp), %rax
	movl	%edx, (%rax)
	movq	-40(%rbp), %rax
	movl	(%rax), %edx
	movq	-48(%rbp), %rax
	movl	%edx, (%rax)
	movq	-40(%rbp), %rax
	movl	-4(%rbp), %edx
	movl	%edx, (%rax)
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE4:
	.size	Right, .-Right
	.globl	Left
	.type	Left, @function
Left:
.LFB5:
	.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)
	movq	%rsi, -32(%rbp)
	movq	%rdx, -40(%rbp)
	movq	%rcx, -48(%rbp)
	movq	-24(%rbp), %rax
	movl	(%rax), %eax
	movl	%eax, -4(%rbp)
	movq	-40(%rbp), %rax
	movl	(%rax), %edx
	movq	-24(%rbp), %rax
	movl	%edx, (%rax)
	movq	-48(%rbp), %rax
	movl	(%rax), %edx
	movq	-40(%rbp), %rax
	movl	%edx, (%rax)
	movq	-32(%rbp), %rax
	movl	(%rax), %edx
	movq	-48(%rbp), %rax
	movl	%edx, (%rax)
	movq	-32(%rbp), %rax
	movl	-4(%rbp), %edx
	movl	%edx, (%rax)
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE5:
	.size	Left, .-Left
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%s"
.LC2:
	.string	"North"
.LC3:
	.string	"East"
.LC4:
	.string	"West"
.LC5:
	.string	"South"
.LC6:
	.string	"Right"
.LC7:
	.string	"Left"
.LC8:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB6:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$64, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
.L20:
	movl	$1, -56(%rbp)
	jmp	.L8
.L9:
	movl	-56(%rbp), %eax
	cltq
	movl	-56(%rbp), %edx
	movl	%edx, -48(%rbp,%rax,4)
	addl	$1, -56(%rbp)
.L8:
	cmpl	$6, -56(%rbp)
	jle	.L9
	movl	$1, -52(%rbp)
	leaq	-60(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-60(%rbp), %eax
	testl	%eax, %eax
	jne	.L10
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L21
	jmp	.L22
.L10:
	movl	$0, -56(%rbp)
	jmp	.L12
.L19:
	leaq	-18(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	leaq	-18(%rbp), %rax
	leaq	.LC2(%rip), %rdx
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	strcmp@PLT
	testl	%eax, %eax
	jne	.L13
	leaq	-48(%rbp), %rax
	leaq	24(%rax), %rcx
	leaq	-48(%rbp), %rax
	leaq	20(%rax), %rdx
	leaq	-48(%rbp), %rax
	leaq	8(%rax), %rsi
	leaq	-48(%rbp), %rax
	addq	$4, %rax
	movq	%rax, %rdi
	call	North
	movl	-44(%rbp), %eax
	addl	%eax, -52(%rbp)
	jmp	.L14
.L13:
	leaq	-18(%rbp), %rax
	leaq	.LC3(%rip), %rdx
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	strcmp@PLT
	testl	%eax, %eax
	jne	.L15
	leaq	-48(%rbp), %rax
	leaq	24(%rax), %rcx
	leaq	-48(%rbp), %rax
	leaq	16(%rax), %rdx
	leaq	-48(%rbp), %rax
	leaq	12(%rax), %rsi
	leaq	-48(%rbp), %rax
	addq	$4, %rax
	movq	%rax, %rdi
	call	East
	movl	-44(%rbp), %eax
	addl	%eax, -52(%rbp)
	jmp	.L14
.L15:
	leaq	-18(%rbp), %rax
	leaq	.LC4(%rip), %rdx
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	strcmp@PLT
	testl	%eax, %eax
	jne	.L16
	leaq	-48(%rbp), %rax
	leaq	24(%rax), %rcx
	leaq	-48(%rbp), %rax
	leaq	16(%rax), %rdx
	leaq	-48(%rbp), %rax
	leaq	12(%rax), %rsi
	leaq	-48(%rbp), %rax
	addq	$4, %rax
	movq	%rax, %rdi
	call	West
	movl	-44(%rbp), %eax
	addl	%eax, -52(%rbp)
	jmp	.L14
.L16:
	leaq	-18(%rbp), %rax
	leaq	.LC5(%rip), %rdx
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	strcmp@PLT
	testl	%eax, %eax
	jne	.L17
	leaq	-48(%rbp), %rax
	leaq	24(%rax), %rcx
	leaq	-48(%rbp), %rax
	leaq	20(%rax), %rdx
	leaq	-48(%rbp), %rax
	leaq	8(%rax), %rsi
	leaq	-48(%rbp), %rax
	addq	$4, %rax
	movq	%rax, %rdi
	call	South
	movl	-44(%rbp), %eax
	addl	%eax, -52(%rbp)
	jmp	.L14
.L17:
	leaq	-18(%rbp), %rax
	leaq	.LC6(%rip), %rdx
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	strcmp@PLT
	testl	%eax, %eax
	jne	.L18
	leaq	-48(%rbp), %rax
	leaq	20(%rax), %rcx
	leaq	-48(%rbp), %rax
	leaq	16(%rax), %rdx
	leaq	-48(%rbp), %rax
	leaq	12(%rax), %rsi
	leaq	-48(%rbp), %rax
	addq	$8, %rax
	movq	%rax, %rdi
	call	Right
	movl	-44(%rbp), %eax
	addl	%eax, -52(%rbp)
	jmp	.L14
.L18:
	leaq	-18(%rbp), %rax
	leaq	.LC7(%rip), %rdx
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	strcmp@PLT
	testl	%eax, %eax
	jne	.L14
	leaq	-48(%rbp), %rax
	leaq	20(%rax), %rcx
	leaq	-48(%rbp), %rax
	leaq	16(%rax), %rdx
	leaq	-48(%rbp), %rax
	leaq	12(%rax), %rsi
	leaq	-48(%rbp), %rax
	addq	$8, %rax
	movq	%rax, %rdi
	call	Left
	movl	-44(%rbp), %eax
	addl	%eax, -52(%rbp)
.L14:
	addl	$1, -56(%rbp)
.L12:
	movl	-60(%rbp), %eax
	cmpl	%eax, -56(%rbp)
	jl	.L19
	movl	-52(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC8(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L20
.L22:
	call	__stack_chk_fail@PLT
.L21:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.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	North
	.type	North, @function
North:
.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)
	movq	%rsi, -32(%rbp)
	movq	%rdx, -40(%rbp)
	movq	%rcx, -48(%rbp)
	movq	-24(%rbp), %rax
	movl	(%rax), %eax
	movl	%eax, -4(%rbp)
	movq	-32(%rbp), %rax
	movl	(%rax), %edx
	movq	-24(%rbp), %rax
	movl	%edx, (%rax)
	movq	-48(%rbp), %rax
	movl	(%rax), %edx
	movq	-32(%rbp), %rax
	movl	%edx, (%rax)
	movq	-40(%rbp), %rax
	movl	(%rax), %edx
	movq	-48(%rbp), %rax
	movl	%edx, (%rax)
	movq	-40(%rbp), %rax
	movl	-4(%rbp), %edx
	movl	%edx, (%rax)
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	North, .-North
	.globl	East
	.type	East, @function
East:
.LFB1:
	.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)
	movq	%rsi, -32(%rbp)
	movq	%rdx, -40(%rbp)
	movq	%rcx, -48(%rbp)
	movq	-24(%rbp), %rax
	movl	(%rax), %eax
	movl	%eax, -4(%rbp)
	movq	-40(%rbp), %rax
	movl	(%rax), %edx
	movq	-24(%rbp), %rax
	movl	%edx, (%rax)
	movq	-48(%rbp), %rax
	movl	(%rax), %edx
	movq	-40(%rbp), %rax
	movl	%edx, (%rax)
	movq	-32(%rbp), %rax
	movl	(%rax), %edx
	movq	-48(%rbp), %rax
	movl	%edx, (%rax)
	movq	-32(%rbp), %rax
	movl	-4(%rbp), %edx
	movl	%edx, (%rax)
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.size	East, .-East
	.globl	West
	.type	West, @function
West:
.LFB2:
	.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)
	movq	%rsi, -32(%rbp)
	movq	%rdx, -40(%rbp)
	movq	%rcx, -48(%rbp)
	movq	-24(%rbp), %rax
	movl	(%rax), %eax
	movl	%eax, -4(%rbp)
	movq	-32(%rbp), %rax
	movl	(%rax), %edx
	movq	-24(%rbp), %rax
	movl	%edx, (%rax)
	movq	-48(%rbp), %rax
	movl	(%rax), %edx
	movq	-32(%rbp), %rax
	movl	%edx, (%rax)
	movq	-40(%rbp), %rax
	movl	(%rax), %edx
	movq	-48(%rbp), %rax
	movl	%edx, (%rax)
	movq	-40(%rbp), %rax
	movl	-4(%rbp), %edx
	movl	%edx, (%rax)
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE2:
	.size	West, .-West
	.globl	South
	.type	South, @function
South:
.LFB3:
	.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)
	movq	%rsi, -32(%rbp)
	movq	%rdx, -40(%rbp)
	movq	%rcx, -48(%rbp)
	movq	-24(%rbp), %rax
	movl	(%rax), %eax
	movl	%eax, -4(%rbp)
	movq	-40(%rbp), %rax
	movl	(%rax), %edx
	movq	-24(%rbp), %rax
	movl	%edx, (%rax)
	movq	-48(%rbp), %rax
	movl	(%rax), %edx
	movq	-40(%rbp), %rax
	movl	%edx, (%rax)
	movq	-32(%rbp), %rax
	movl	(%rax), %edx
	movq	-48(%rbp), %rax
	movl	%edx, (%rax)
	movq	-32(%rbp), %rax
	movl	-4(%rbp), %edx
	movl	%edx, (%rax)
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE3:
	.size	South, .-South
	.globl	Right
	.type	Right, @function
Right:
.LFB4:
	.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)
	movq	%rsi, -32(%rbp)
	movq	%rdx, -40(%rbp)
	movq	%rcx, -48(%rbp)
	movq	-24(%rbp), %rax
	movl	(%rax), %eax
	movl	%eax, -4(%rbp)
	movq	-32(%rbp), %rax
	movl	(%rax), %edx
	movq	-24(%rbp), %rax
	movl	%edx, (%rax)
	movq	-48(%rbp), %rax
	movl	(%rax), %edx
	movq	-32(%rbp), %rax
	movl	%edx, (%rax)
	movq	-40(%rbp), %rax
	movl	(%rax), %edx
	movq	-48(%rbp), %rax
	movl	%edx, (%rax)
	movq	-40(%rbp), %rax
	movl	-4(%rbp), %edx
	movl	%edx, (%rax)
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE4:
	.size	Right, .-Right
	.globl	Left
	.type	Left, @function
Left:
.LFB5:
	.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)
	movq	%rsi, -32(%rbp)
	movq	%rdx, -40(%rbp)
	movq	%rcx, -48(%rbp)
	movq	-24(%rbp), %rax
	movl	(%rax), %eax
	movl	%eax, -4(%rbp)
	movq	-40(%rbp), %rax
	movl	(%rax), %edx
	movq	-24(%rbp), %rax
	movl	%edx, (%rax)
	movq	-48(%rbp), %rax
	movl	(%rax), %edx
	movq	-40(%rbp), %rax
	movl	%edx, (%rax)
	movq	-32(%rbp), %rax
	movl	(%rax), %edx
	movq	-48(%rbp), %rax
	movl	%edx, (%rax)
	movq	-32(%rbp), %rax
	movl	-4(%rbp), %edx
	movl	%edx, (%rax)
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE5:
	.size	Left, .-Left
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%s"
.LC2:
	.string	"North"
.LC3:
	.string	"East"
.LC4:
	.string	"West"
.LC5:
	.string	"South"
.LC6:
	.string	"Right"
.LC7:
	.string	"Left"
.LC8:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB6:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$64, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
.L20:
	movl	$1, -56(%rbp)
	jmp	.L8
.L9:
	movl	-56(%rbp), %eax
	cltq
	movl	-56(%rbp), %edx
	movl	%edx, -48(%rbp,%rax,4)
	addl	$1, -56(%rbp)
.L8:
	cmpl	$6, -56(%rbp)
	jle	.L9
	movl	$1, -52(%rbp)
	leaq	-60(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-60(%rbp), %eax
	testl	%eax, %eax
	jne	.L10
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L21
	jmp	.L22
.L10:
	movl	$0, -56(%rbp)
	jmp	.L12
.L19:
	leaq	-18(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	leaq	-18(%rbp), %rax
	leaq	.LC2(%rip), %rdx
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	strcmp@PLT
	testl	%eax, %eax
	jne	.L13
	leaq	-48(%rbp), %rax
	leaq	24(%rax), %rcx
	leaq	-48(%rbp), %rax
	leaq	20(%rax), %rdx
	leaq	-48(%rbp), %rax
	leaq	8(%rax), %rsi
	leaq	-48(%rbp), %rax
	addq	$4, %rax
	movq	%rax, %rdi
	call	North
	movl	-44(%rbp), %eax
	addl	%eax, -52(%rbp)
	jmp	.L14
.L13:
	leaq	-18(%rbp), %rax
	leaq	.LC3(%rip), %rdx
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	strcmp@PLT
	testl	%eax, %eax
	jne	.L15
	leaq	-48(%rbp), %rax
	leaq	24(%rax), %rcx
	leaq	-48(%rbp), %rax
	leaq	16(%rax), %rdx
	leaq	-48(%rbp), %rax
	leaq	12(%rax), %rsi
	leaq	-48(%rbp), %rax
	addq	$4, %rax
	movq	%rax, %rdi
	call	East
	movl	-44(%rbp), %eax
	addl	%eax, -52(%rbp)
	jmp	.L14
.L15:
	leaq	-18(%rbp), %rax
	leaq	.LC4(%rip), %rdx
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	strcmp@PLT
	testl	%eax, %eax
	jne	.L16
	leaq	-48(%rbp), %rax
	leaq	24(%rax), %rcx
	leaq	-48(%rbp), %rax
	leaq	16(%rax), %rdx
	leaq	-48(%rbp), %rax
	leaq	12(%rax), %rsi
	leaq	-48(%rbp), %rax
	addq	$4, %rax
	movq	%rax, %rdi
	call	West
	movl	-44(%rbp), %eax
	addl	%eax, -52(%rbp)
	jmp	.L14
.L16:
	leaq	-18(%rbp), %rax
	leaq	.LC5(%rip), %rdx
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	strcmp@PLT
	testl	%eax, %eax
	jne	.L17
	leaq	-48(%rbp), %rax
	leaq	24(%rax), %rcx
	leaq	-48(%rbp), %rax
	leaq	20(%rax), %rdx
	leaq	-48(%rbp), %rax
	leaq	8(%rax), %rsi
	leaq	-48(%rbp), %rax
	addq	$4, %rax
	movq	%rax, %rdi
	call	South
	movl	-44(%rbp), %eax
	addl	%eax, -52(%rbp)
	jmp	.L14
.L17:
	leaq	-18(%rbp), %rax
	leaq	.LC6(%rip), %rdx
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	strcmp@PLT
	testl	%eax, %eax
	jne	.L18
	leaq	-48(%rbp), %rax
	leaq	20(%rax), %rcx
	leaq	-48(%rbp), %rax
	leaq	16(%rax), %rdx
	leaq	-48(%rbp), %rax
	leaq	12(%rax), %rsi
	leaq	-48(%rbp), %rax
	addq	$8, %rax
	movq	%rax, %rdi
	call	Right
	movl	-44(%rbp), %eax
	addl	%eax, -52(%rbp)
	jmp	.L14
.L18:
	leaq	-18(%rbp), %rax
	leaq	.LC7(%rip), %rdx
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	strcmp@PLT
	testl	%eax, %eax
	jne	.L14
	leaq	-48(%rbp), %rax
	leaq	20(%rax), %rcx
	leaq	-48(%rbp), %rax
	leaq	16(%rax), %rdx
	leaq	-48(%rbp), %rax
	leaq	12(%rax), %rsi
	leaq	-48(%rbp), %rax
	addq	$8, %rax
	movq	%rax, %rdi
	call	Left
	movl	-44(%rbp), %eax
	addl	%eax, -52(%rbp)
.L14:
	addl	$1, -56(%rbp)
.L12:
	movl	-60(%rbp), %eax
	cmpl	%eax, -56(%rbp)
	jl	.L19
	movl	-52(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC8(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L20
.L22:
	call	__stack_chk_fail@PLT
.L21:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.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:
