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>
int main(){
  int tai,n,i,count;
  char c[100][3];
  while(1){
    count=0;
    tai=0;
    scanf("%d",&n);
    if(n==0)break;
 
    for(i=0;i<n;i++){
      scanf(" %s", c[i]);
    }

    
    if(n==1){printf("0\n");continue;}
  else if(n!=0){
  for(i=1;i<n;i++){
    if(tai==0 && c[i-1][0]=='l' && c[i-1][1]=='u' && c[i][0]=='r' && c[i][1]=='u'){count++;tai=1;}
    if(tai==0 && c[i-1][0]=='r' && c[i-1][1]=='u' && c[i][0]=='l' && c[i][1]=='u'){count++;tai=1;}
    if(tai==1 && c[i-1][0]=='l' && c[i-1][1]=='d' && c[i][0]=='r' && c[i][1]=='d'){count++;tai=0;}
    if(tai==1 && c[i-1][0]=='r' && c[i-1][1]=='d' && c[i][0]=='l' && c[i][1]=='d'){count++;tai=0;}
  }
  }
  






  printf("%d\n",count);
  }
  
  return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	" %s"
.LC2:
	.string	"0"
.LC3:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$336, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
.L15:
	movl	$0, -324(%rbp)
	movl	$0, -332(%rbp)
	leaq	-336(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-336(%rbp), %eax
	testl	%eax, %eax
	je	.L19
	movl	$0, -328(%rbp)
	jmp	.L4
.L5:
	leaq	-320(%rbp), %rcx
	movl	-328(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	addq	%rcx, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -328(%rbp)
.L4:
	movl	-336(%rbp), %eax
	cmpl	%eax, -328(%rbp)
	jl	.L5
	movl	-336(%rbp), %eax
	cmpl	$1, %eax
	jne	.L6
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	jmp	.L7
.L6:
	movl	-336(%rbp), %eax
	testl	%eax, %eax
	je	.L8
	movl	$1, -328(%rbp)
	jmp	.L9
.L14:
	cmpl	$0, -332(%rbp)
	jne	.L10
	movl	-328(%rbp), %eax
	subl	$1, %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	addq	%rbp, %rax
	subq	$320, %rax
	movzbl	(%rax), %eax
	cmpb	$108, %al
	jne	.L10
	movl	-328(%rbp), %eax
	subl	$1, %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	addq	%rbp, %rax
	subq	$319, %rax
	movzbl	(%rax), %eax
	cmpb	$117, %al
	jne	.L10
	movl	-328(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	addq	%rbp, %rax
	subq	$320, %rax
	movzbl	(%rax), %eax
	cmpb	$114, %al
	jne	.L10
	movl	-328(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	addq	%rbp, %rax
	subq	$319, %rax
	movzbl	(%rax), %eax
	cmpb	$117, %al
	jne	.L10
	addl	$1, -324(%rbp)
	movl	$1, -332(%rbp)
.L10:
	cmpl	$0, -332(%rbp)
	jne	.L11
	movl	-328(%rbp), %eax
	subl	$1, %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	addq	%rbp, %rax
	subq	$320, %rax
	movzbl	(%rax), %eax
	cmpb	$114, %al
	jne	.L11
	movl	-328(%rbp), %eax
	subl	$1, %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	addq	%rbp, %rax
	subq	$319, %rax
	movzbl	(%rax), %eax
	cmpb	$117, %al
	jne	.L11
	movl	-328(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	addq	%rbp, %rax
	subq	$320, %rax
	movzbl	(%rax), %eax
	cmpb	$108, %al
	jne	.L11
	movl	-328(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	addq	%rbp, %rax
	subq	$319, %rax
	movzbl	(%rax), %eax
	cmpb	$117, %al
	jne	.L11
	addl	$1, -324(%rbp)
	movl	$1, -332(%rbp)
.L11:
	cmpl	$1, -332(%rbp)
	jne	.L12
	movl	-328(%rbp), %eax
	subl	$1, %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	addq	%rbp, %rax
	subq	$320, %rax
	movzbl	(%rax), %eax
	cmpb	$108, %al
	jne	.L12
	movl	-328(%rbp), %eax
	subl	$1, %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	addq	%rbp, %rax
	subq	$319, %rax
	movzbl	(%rax), %eax
	cmpb	$100, %al
	jne	.L12
	movl	-328(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	addq	%rbp, %rax
	subq	$320, %rax
	movzbl	(%rax), %eax
	cmpb	$114, %al
	jne	.L12
	movl	-328(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	addq	%rbp, %rax
	subq	$319, %rax
	movzbl	(%rax), %eax
	cmpb	$100, %al
	jne	.L12
	addl	$1, -324(%rbp)
	movl	$0, -332(%rbp)
.L12:
	cmpl	$1, -332(%rbp)
	jne	.L13
	movl	-328(%rbp), %eax
	subl	$1, %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	addq	%rbp, %rax
	subq	$320, %rax
	movzbl	(%rax), %eax
	cmpb	$114, %al
	jne	.L13
	movl	-328(%rbp), %eax
	subl	$1, %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	addq	%rbp, %rax
	subq	$319, %rax
	movzbl	(%rax), %eax
	cmpb	$100, %al
	jne	.L13
	movl	-328(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	addq	%rbp, %rax
	subq	$320, %rax
	movzbl	(%rax), %eax
	cmpb	$108, %al
	jne	.L13
	movl	-328(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	addq	%rbp, %rax
	subq	$319, %rax
	movzbl	(%rax), %eax
	cmpb	$100, %al
	jne	.L13
	addl	$1, -324(%rbp)
	movl	$0, -332(%rbp)
.L13:
	addl	$1, -328(%rbp)
.L9:
	movl	-336(%rbp), %eax
	cmpl	%eax, -328(%rbp)
	jl	.L14
.L8:
	movl	-324(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L7:
	jmp	.L15
.L19:
	nop
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L17
	call	__stack_chk_fail@PLT
.L17:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.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
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d"
.LC1:
	.string	" %s"
.LC2:
	.string	"0"
.LC3:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB23:
	.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
	leaq	.LC3(%rip), %r14
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	leaq	.LC0(%rip), %r12
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$360, %rsp
	.cfi_def_cfa_offset 416
	movq	%fs:40, %rax
	movq	%rax, 344(%rsp)
	xorl	%eax, %eax
	leaq	32(%rsp), %rax
	leaq	28(%rsp), %r13
	movq	%rax, 8(%rsp)
	.p2align 4,,10
	.p2align 3
.L2:
	movq	%r13, %rsi
	movq	%r12, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	28(%rsp), %eax
	testl	%eax, %eax
	je	.L3
	jle	.L4
	leaq	32(%rsp), %r15
	xorl	%ebx, %ebx
	leaq	.LC1(%rip), %rbp
	.p2align 4,,10
	.p2align 3
.L5:
	movq	%r15, %rsi
	movq	%rbp, %rdi
	xorl	%eax, %eax
	addl	$1, %ebx
	call	__isoc99_scanf@PLT
	movl	28(%rsp), %eax
	addq	$3, %r15
	cmpl	%ebx, %eax
	jg	.L5
	cmpl	$1, %eax
	je	.L41
	testl	%eax, %eax
	jne	.L4
.L8:
	xorl	%r8d, %r8d
.L17:
	movl	%r8d, %edx
	movq	%r14, %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L2
	.p2align 4,,10
	.p2align 3
.L4:
	xorl	%r8d, %r8d
	movl	$1, %edx
	cmpl	$1, %eax
	jg	.L9
	jmp	.L8
	.p2align 4,,10
	.p2align 3
.L10:
	cmpb	$114, %r9b
	jne	.L11
	cmpb	$117, 33(%rsp,%rcx)
	je	.L42
.L11:
	addl	$1, %edx
	cmpl	%eax, %edx
	jge	.L17
.L9:
	leal	2(%r8), %esi
	leal	1(%r8), %edi
.L23:
	leal	-1(%rdx), %ecx
	leal	-2(%rsi), %r8d
	movslq	%ecx, %rcx
	leaq	(%rcx,%rcx,2), %rcx
	movzbl	32(%rsp,%rcx), %r9d
	cmpb	$108, %r9b
	jne	.L10
	cmpb	$117, 33(%rsp,%rcx)
	jne	.L11
	movslq	%edx, %rcx
	leaq	(%rcx,%rcx,2), %r9
	cmpb	$114, 32(%rsp,%r9)
	jne	.L11
.L39:
	cmpb	$117, 33(%rsp,%r9)
	jne	.L11
	leaq	(%rcx,%rcx,2), %rcx
	movl	%edi, %r8d
	addq	8(%rsp), %rcx
	jmp	.L13
	.p2align 4,,10
	.p2align 3
.L14:
	cmpb	$114, %r9b
	jne	.L21
	cmpb	$100, -2(%rcx)
	je	.L20
.L21:
	cmpl	%edx, %eax
	jle	.L17
	addq	$3, %rcx
.L13:
	movzbl	-3(%rcx), %r9d
	addl	$1, %edx
	cmpb	$108, %r9b
	jne	.L14
	cmpb	$100, -2(%rcx)
	jne	.L21
	cmpb	$114, (%rcx)
	jne	.L21
.L37:
	cmpb	$100, 1(%rcx)
	jne	.L21
	movl	%esi, %r8d
	cmpl	%edx, %eax
	jle	.L17
	addl	$2, %esi
	addl	$2, %edi
	jmp	.L23
	.p2align 4,,10
	.p2align 3
.L3:
	movq	344(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L43
	addq	$360, %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
.L42:
	.cfi_restore_state
	movslq	%edx, %rcx
	leaq	(%rcx,%rcx,2), %r9
	cmpb	$108, 32(%rsp,%r9)
	jne	.L11
	jmp	.L39
	.p2align 4,,10
	.p2align 3
.L41:
	leaq	.LC2(%rip), %rdi
	call	puts@PLT
	jmp	.L2
.L20:
	cmpb	$108, (%rcx)
	jne	.L21
	jmp	.L37
.L43:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE23:
	.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
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d"
.LC1:
	.string	" %s"
.LC2:
	.string	"0"
.LC3:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB23:
	.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
	leaq	.LC3(%rip), %r14
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	leaq	.LC0(%rip), %r12
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$360, %rsp
	.cfi_def_cfa_offset 416
	movq	%fs:40, %rax
	movq	%rax, 344(%rsp)
	xorl	%eax, %eax
	leaq	32(%rsp), %rax
	leaq	28(%rsp), %r13
	movq	%rax, 8(%rsp)
	.p2align 4,,10
	.p2align 3
.L2:
	movq	%r13, %rsi
	movq	%r12, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	28(%rsp), %eax
	testl	%eax, %eax
	je	.L3
	jle	.L4
	leaq	32(%rsp), %r15
	xorl	%ebx, %ebx
	leaq	.LC1(%rip), %rbp
	.p2align 4,,10
	.p2align 3
.L5:
	movq	%r15, %rsi
	movq	%rbp, %rdi
	xorl	%eax, %eax
	addl	$1, %ebx
	call	__isoc99_scanf@PLT
	movl	28(%rsp), %eax
	addq	$3, %r15
	cmpl	%ebx, %eax
	jg	.L5
	cmpl	$1, %eax
	je	.L41
	testl	%eax, %eax
	jne	.L4
.L8:
	xorl	%r8d, %r8d
.L17:
	movl	%r8d, %edx
	movq	%r14, %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L2
	.p2align 4,,10
	.p2align 3
.L4:
	xorl	%r8d, %r8d
	movl	$1, %edx
	cmpl	$1, %eax
	jg	.L9
	jmp	.L8
	.p2align 4,,10
	.p2align 3
.L10:
	cmpb	$114, %r9b
	jne	.L11
	cmpb	$117, 33(%rsp,%rcx)
	je	.L42
.L11:
	addl	$1, %edx
	cmpl	%eax, %edx
	jge	.L17
.L9:
	leal	2(%r8), %esi
	leal	1(%r8), %edi
.L23:
	leal	-1(%rdx), %ecx
	leal	-2(%rsi), %r8d
	movslq	%ecx, %rcx
	leaq	(%rcx,%rcx,2), %rcx
	movzbl	32(%rsp,%rcx), %r9d
	cmpb	$108, %r9b
	jne	.L10
	cmpb	$117, 33(%rsp,%rcx)
	jne	.L11
	movslq	%edx, %rcx
	leaq	(%rcx,%rcx,2), %r9
	cmpb	$114, 32(%rsp,%r9)
	jne	.L11
.L39:
	cmpb	$117, 33(%rsp,%r9)
	jne	.L11
	leaq	(%rcx,%rcx,2), %rcx
	movl	%edi, %r8d
	addq	8(%rsp), %rcx
	jmp	.L13
	.p2align 4,,10
	.p2align 3
.L14:
	cmpb	$114, %r9b
	jne	.L21
	cmpb	$100, -2(%rcx)
	je	.L20
.L21:
	cmpl	%edx, %eax
	jle	.L17
	addq	$3, %rcx
.L13:
	movzbl	-3(%rcx), %r9d
	addl	$1, %edx
	cmpb	$108, %r9b
	jne	.L14
	cmpb	$100, -2(%rcx)
	jne	.L21
	cmpb	$114, (%rcx)
	jne	.L21
.L37:
	cmpb	$100, 1(%rcx)
	jne	.L21
	movl	%esi, %r8d
	cmpl	%edx, %eax
	jle	.L17
	addl	$2, %esi
	addl	$2, %edi
	jmp	.L23
	.p2align 4,,10
	.p2align 3
.L3:
	movq	344(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L43
	addq	$360, %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
.L42:
	.cfi_restore_state
	movslq	%edx, %rcx
	leaq	(%rcx,%rcx,2), %r9
	cmpb	$108, 32(%rsp,%r9)
	jne	.L11
	jmp	.L39
	.p2align 4,,10
	.p2align 3
.L41:
	leaq	.LC2(%rip), %rdi
	call	puts@PLT
	jmp	.L2
.L20:
	cmpb	$108, (%rcx)
	jne	.L21
	jmp	.L37
.L43:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE23:
	.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>
int main(){
  int tai,n,i,count;
  char c[100][3];
  while(1){
    count=0;
    tai=0;
    scanf("%d",&n);
    if(n==0)break;
 
    for(i=0;i<n;i++){
      scanf(" %s", c[i]);
    }

    
    if(n==1){printf("0\n");continue;}
  else if(n!=0){
  for(i=1;i<n;i++){
    if(tai==0 && c[i-1][0]=='l' && c[i-1][1]=='u' && c[i][0]=='r' && c[i][1]=='u'){count++;tai=1;}
    if(tai==0 && c[i-1][0]=='r' && c[i-1][1]=='u' && c[i][0]=='l' && c[i][1]=='u'){count++;tai=1;}
    if(tai==1 && c[i-1][0]=='l' && c[i-1][1]=='d' && c[i][0]=='r' && c[i][1]=='d'){count++;tai=0;}
    if(tai==1 && c[i-1][0]=='r' && c[i-1][1]=='d' && c[i][0]=='l' && c[i][1]=='d'){count++;tai=0;}
  }
  }
  






  printf("%d\n",count);
  }
  
  return 0;
}
4
lu ru ld rd
4
lu ld lu ru
0
lu
10
ru lu ld rd ru rd ru lu rd ld
0
 4
lu ru ld rd
0
lu ld lu ru
0
ul
10
vr lu ld rd rv rd ru lu rc kd
0
 4
lu ru ld rd
4
lu ld lu ru
0
ul
10
ru lu ld rd ru rd ru lu rd ld
0
 4
lu ru ld rd
4
lu ld lu ru
0
lu
10
ru lu ld rd su rd ru lu rd ld
0
 4
lu ru ld rd
4
lu ld lu ru
0
ul
10
ru lu ld rd rt rd ru lu rd ld
0
 4
lu ru ld rd
4
lu ld lu ru
0
lu
10
ru lu ld rd su rd ru lu sd ld
0
 4
lu ru ld rd
4
lu ld lu ru
0
ul
10
ru lu ld rd rt dr ru lu rd ld
0
 4
lu ru ld rd
4
lu ld lu ru
0
lu
10
ru lu ld dr su rd ru lu sd ld
0
 4
lu ru ld rd
4
lu ld lu ru
0
ul
10
ru lu ld rd rt dr ru lu rd dl
0
 4
lu ru ld rd
4
lu ld lu ru
0
lu
10
ru lu ld rd ru rd ru lu rc ld
0

2
1
 2
 2
1
 2
1
 2
1
 2
1
 2
1
 2
1
 2
1
 2
1

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>
int main(){
  int tai,n,i,count;
  char c[100][3];
  while(1){
    count=0;
    tai=0;
    scanf("%d",&n);
    if(n==0)break;
 
    for(i=0;i<n;i++){
      scanf(" %s", c[i]);
    }

    
    if(n==1){printf("0\n");continue;}
  else if(n!=0){
  for(i=1;i<n;i++){
    if(tai==0 && c[i-1][0]=='l' && c[i-1][1]=='u' && c[i][0]=='r' && c[i][1]=='u'){count++;tai=1;}
    if(tai==0 && c[i-1][0]=='r' && c[i-1][1]=='u' && c[i][0]=='l' && c[i][1]=='u'){count++;tai=1;}
    if(tai==1 && c[i-1][0]=='l' && c[i-1][1]=='d' && c[i][0]=='r' && c[i][1]=='d'){count++;tai=0;}
    if(tai==1 && c[i-1][0]=='r' && c[i-1][1]=='d' && c[i][0]=='l' && c[i][1]=='d'){count++;tai=0;}
  }
  }
  






  printf("%d\n",count);
  }
  
  return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	" %s"
.LC2:
	.string	"0"
.LC3:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$336, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
.L15:
	movl	$0, -324(%rbp)
	movl	$0, -332(%rbp)
	leaq	-336(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-336(%rbp), %eax
	testl	%eax, %eax
	je	.L19
	movl	$0, -328(%rbp)
	jmp	.L4
.L5:
	leaq	-320(%rbp), %rcx
	movl	-328(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	addq	%rcx, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -328(%rbp)
.L4:
	movl	-336(%rbp), %eax
	cmpl	%eax, -328(%rbp)
	jl	.L5
	movl	-336(%rbp), %eax
	cmpl	$1, %eax
	jne	.L6
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	jmp	.L7
.L6:
	movl	-336(%rbp), %eax
	testl	%eax, %eax
	je	.L8
	movl	$1, -328(%rbp)
	jmp	.L9
.L14:
	cmpl	$0, -332(%rbp)
	jne	.L10
	movl	-328(%rbp), %eax
	subl	$1, %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	addq	%rbp, %rax
	subq	$320, %rax
	movzbl	(%rax), %eax
	cmpb	$108, %al
	jne	.L10
	movl	-328(%rbp), %eax
	subl	$1, %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	addq	%rbp, %rax
	subq	$319, %rax
	movzbl	(%rax), %eax
	cmpb	$117, %al
	jne	.L10
	movl	-328(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	addq	%rbp, %rax
	subq	$320, %rax
	movzbl	(%rax), %eax
	cmpb	$114, %al
	jne	.L10
	movl	-328(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	addq	%rbp, %rax
	subq	$319, %rax
	movzbl	(%rax), %eax
	cmpb	$117, %al
	jne	.L10
	addl	$1, -324(%rbp)
	movl	$1, -332(%rbp)
.L10:
	cmpl	$0, -332(%rbp)
	jne	.L11
	movl	-328(%rbp), %eax
	subl	$1, %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	addq	%rbp, %rax
	subq	$320, %rax
	movzbl	(%rax), %eax
	cmpb	$114, %al
	jne	.L11
	movl	-328(%rbp), %eax
	subl	$1, %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	addq	%rbp, %rax
	subq	$319, %rax
	movzbl	(%rax), %eax
	cmpb	$117, %al
	jne	.L11
	movl	-328(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	addq	%rbp, %rax
	subq	$320, %rax
	movzbl	(%rax), %eax
	cmpb	$108, %al
	jne	.L11
	movl	-328(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	addq	%rbp, %rax
	subq	$319, %rax
	movzbl	(%rax), %eax
	cmpb	$117, %al
	jne	.L11
	addl	$1, -324(%rbp)
	movl	$1, -332(%rbp)
.L11:
	cmpl	$1, -332(%rbp)
	jne	.L12
	movl	-328(%rbp), %eax
	subl	$1, %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	addq	%rbp, %rax
	subq	$320, %rax
	movzbl	(%rax), %eax
	cmpb	$108, %al
	jne	.L12
	movl	-328(%rbp), %eax
	subl	$1, %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	addq	%rbp, %rax
	subq	$319, %rax
	movzbl	(%rax), %eax
	cmpb	$100, %al
	jne	.L12
	movl	-328(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	addq	%rbp, %rax
	subq	$320, %rax
	movzbl	(%rax), %eax
	cmpb	$114, %al
	jne	.L12
	movl	-328(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	addq	%rbp, %rax
	subq	$319, %rax
	movzbl	(%rax), %eax
	cmpb	$100, %al
	jne	.L12
	addl	$1, -324(%rbp)
	movl	$0, -332(%rbp)
.L12:
	cmpl	$1, -332(%rbp)
	jne	.L13
	movl	-328(%rbp), %eax
	subl	$1, %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	addq	%rbp, %rax
	subq	$320, %rax
	movzbl	(%rax), %eax
	cmpb	$114, %al
	jne	.L13
	movl	-328(%rbp), %eax
	subl	$1, %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	addq	%rbp, %rax
	subq	$319, %rax
	movzbl	(%rax), %eax
	cmpb	$100, %al
	jne	.L13
	movl	-328(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	addq	%rbp, %rax
	subq	$320, %rax
	movzbl	(%rax), %eax
	cmpb	$108, %al
	jne	.L13
	movl	-328(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	addq	%rbp, %rax
	subq	$319, %rax
	movzbl	(%rax), %eax
	cmpb	$100, %al
	jne	.L13
	addl	$1, -324(%rbp)
	movl	$0, -332(%rbp)
.L13:
	addl	$1, -328(%rbp)
.L9:
	movl	-336(%rbp), %eax
	cmpl	%eax, -328(%rbp)
	jl	.L14
.L8:
	movl	-324(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L7:
	jmp	.L15
.L19:
	nop
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L17
	call	__stack_chk_fail@PLT
.L17:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	main, .-main
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:
```

Only output the optimized assembly code. Do not include any other text. Do not write any comments in the assembly code. Wrap the assembly code in ```assembly``` tags.
train
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	" %s"
.LC2:
	.string	"0"
.LC3:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$336, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
.L15:
	movl	$0, -324(%rbp)
	movl	$0, -332(%rbp)
	leaq	-336(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-336(%rbp), %eax
	testl	%eax, %eax
	je	.L19
	movl	$0, -328(%rbp)
	jmp	.L4
.L5:
	leaq	-320(%rbp), %rcx
	movl	-328(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	addq	%rcx, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -328(%rbp)
.L4:
	movl	-336(%rbp), %eax
	cmpl	%eax, -328(%rbp)
	jl	.L5
	movl	-336(%rbp), %eax
	cmpl	$1, %eax
	jne	.L6
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	jmp	.L7
.L6:
	movl	-336(%rbp), %eax
	testl	%eax, %eax
	je	.L8
	movl	$1, -328(%rbp)
	jmp	.L9
.L14:
	cmpl	$0, -332(%rbp)
	jne	.L10
	movl	-328(%rbp), %eax
	subl	$1, %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	addq	%rbp, %rax
	subq	$320, %rax
	movzbl	(%rax), %eax
	cmpb	$108, %al
	jne	.L10
	movl	-328(%rbp), %eax
	subl	$1, %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	addq	%rbp, %rax
	subq	$319, %rax
	movzbl	(%rax), %eax
	cmpb	$117, %al
	jne	.L10
	movl	-328(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	addq	%rbp, %rax
	subq	$320, %rax
	movzbl	(%rax), %eax
	cmpb	$114, %al
	jne	.L10
	movl	-328(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	addq	%rbp, %rax
	subq	$319, %rax
	movzbl	(%rax), %eax
	cmpb	$117, %al
	jne	.L10
	addl	$1, -324(%rbp)
	movl	$1, -332(%rbp)
.L10:
	cmpl	$0, -332(%rbp)
	jne	.L11
	movl	-328(%rbp), %eax
	subl	$1, %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	addq	%rbp, %rax
	subq	$320, %rax
	movzbl	(%rax), %eax
	cmpb	$114, %al
	jne	.L11
	movl	-328(%rbp), %eax
	subl	$1, %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	addq	%rbp, %rax
	subq	$319, %rax
	movzbl	(%rax), %eax
	cmpb	$117, %al
	jne	.L11
	movl	-328(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	addq	%rbp, %rax
	subq	$320, %rax
	movzbl	(%rax), %eax
	cmpb	$108, %al
	jne	.L11
	movl	-328(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	addq	%rbp, %rax
	subq	$319, %rax
	movzbl	(%rax), %eax
	cmpb	$117, %al
	jne	.L11
	addl	$1, -324(%rbp)
	movl	$1, -332(%rbp)
.L11:
	cmpl	$1, -332(%rbp)
	jne	.L12
	movl	-328(%rbp), %eax
	subl	$1, %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	addq	%rbp, %rax
	subq	$320, %rax
	movzbl	(%rax), %eax
	cmpb	$108, %al
	jne	.L12
	movl	-328(%rbp), %eax
	subl	$1, %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	addq	%rbp, %rax
	subq	$319, %rax
	movzbl	(%rax), %eax
	cmpb	$100, %al
	jne	.L12
	movl	-328(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	addq	%rbp, %rax
	subq	$320, %rax
	movzbl	(%rax), %eax
	cmpb	$114, %al
	jne	.L12
	movl	-328(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	addq	%rbp, %rax
	subq	$319, %rax
	movzbl	(%rax), %eax
	cmpb	$100, %al
	jne	.L12
	addl	$1, -324(%rbp)
	movl	$0, -332(%rbp)
.L12:
	cmpl	$1, -332(%rbp)
	jne	.L13
	movl	-328(%rbp), %eax
	subl	$1, %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	addq	%rbp, %rax
	subq	$320, %rax
	movzbl	(%rax), %eax
	cmpb	$114, %al
	jne	.L13
	movl	-328(%rbp), %eax
	subl	$1, %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	addq	%rbp, %rax
	subq	$319, %rax
	movzbl	(%rax), %eax
	cmpb	$100, %al
	jne	.L13
	movl	-328(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	addq	%rbp, %rax
	subq	$320, %rax
	movzbl	(%rax), %eax
	cmpb	$108, %al
	jne	.L13
	movl	-328(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	addq	%rbp, %rax
	subq	$319, %rax
	movzbl	(%rax), %eax
	cmpb	$100, %al
	jne	.L13
	addl	$1, -324(%rbp)
	movl	$0, -332(%rbp)
.L13:
	addl	$1, -328(%rbp)
.L9:
	movl	-336(%rbp), %eax
	cmpl	%eax, -328(%rbp)
	jl	.L14
.L8:
	movl	-324(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L7:
	jmp	.L15
.L19:
	nop
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L17
	call	__stack_chk_fail@PLT
.L17:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.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:
