Given the following C code and assembly code, your task is to generate highly optimized x86-64 assembly code.
C Code:

```c
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int	max(int a, int b)
{
  if (a > b)
    return (a);
  else
    return (b);
}

int	main(void)
{
  int	n;
  char	*s;
  int	i;
  int	nR;
  int	nW;
  char	*cR;
  char	*cW;
  char	*tmp;
  int	count;
  int	m;
  
  if (scanf("%d", &n) == EOF)
    return (-1);
  if (!(s = (char *)malloc((n + 1) * sizeof(char))))
    return (-1);
  s[n] = '\0';
  if (scanf("%s", s) == EOF)
  {
    free(s);
    return (-1);
  }
  i = 0;
  nR = 0;
  nW = 0;
  while (s[i])
  {
    if (s[i] == 'R')
      nR++;
    else if (s[i] == 'W')
      nW++;
    i++;
  }
  if (nR == 0 || nW == 0)
    printf("0\n");
  else
  {
    m = max(nR, nW);
    count = 0;
    while (count < m)
    {
	  	cW = strchr(s, 'W');
      	cR = strrchr(s, 'R');
      	if (cW > cR)
          break ;
      	else
        {
          *cW = 'R';
          *cR = 'W';
          count++;
        }
    }
    printf("%d\n", count);
  }
  free(s);
  return (0);
}```

Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.p2align 4
	.globl	max
	.type	max, @function
max:
.LFB51:
	.cfi_startproc
	endbr64
	cmpl	%esi, %edi
	movl	%esi, %eax
	cmovge	%edi, %eax
	ret
	.cfi_endproc
.LFE51:
	.size	max, .-max
	.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:
.LFB52:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	leaq	.LC0(%rip), %rdi
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	subq	$40, %rsp
	.cfi_def_cfa_offset 80
	movq	%fs:40, %rax
	movq	%rax, 24(%rsp)
	xorl	%eax, %eax
	leaq	20(%rsp), %rsi
	call	__isoc99_scanf@PLT
	cmpl	$-1, %eax
	je	.L6
	movslq	20(%rsp), %rbx
	leal	1(%rbx), %edi
	movslq	%edi, %rdi
	call	malloc@PLT
	movq	%rax, %rbp
	testq	%rax, %rax
	je	.L6
	movb	$0, (%rax,%rbx)
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	cmpl	$-1, %eax
	je	.L7
	movzbl	0(%rbp), %eax
	leaq	1(%rbp), %rdx
	xorl	%ecx, %ecx
	xorl	%r12d, %r12d
	testb	%al, %al
	jne	.L12
	jmp	.L9
	.p2align 4,,10
	.p2align 3
.L10:
	cmpb	$87, %al
	sete	%al
	addq	$1, %rdx
	movzbl	%al, %eax
	addl	%eax, %ecx
	movzbl	-1(%rdx), %eax
	testb	%al, %al
	je	.L28
.L12:
	cmpb	$82, %al
	jne	.L10
	movzbl	(%rdx), %eax
	addq	$1, %rdx
	addl	$1, %r12d
	testb	%al, %al
	jne	.L12
.L28:
	testl	%r12d, %r12d
	je	.L9
	testl	%ecx, %ecx
	sete	%al
	cmpl	%ecx, %r12d
	cmovl	%ecx, %r12d
	xorl	%r13d, %r13d
	testb	%al, %al
	jne	.L9
	.p2align 4,,10
	.p2align 3
.L17:
	movl	$87, %esi
	movq	%rbp, %rdi
	call	strchr@PLT
	movl	$82, %esi
	movq	%rbp, %rdi
	movq	%rax, %rbx
	call	strrchr@PLT
	cmpq	%rax, %rbx
	ja	.L16
	addl	$1, %r13d
	movb	$82, (%rbx)
	movb	$87, (%rax)
	cmpl	%r13d, %r12d
	jne	.L17
.L16:
	movl	%r13d, %edx
	leaq	.LC3(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L15:
	movq	%rbp, %rdi
	call	free@PLT
	xorl	%eax, %eax
.L3:
	movq	24(%rsp), %rdx
	subq	%fs:40, %rdx
	jne	.L29
	addq	$40, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 40
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%rbp
	.cfi_def_cfa_offset 24
	popq	%r12
	.cfi_def_cfa_offset 16
	popq	%r13
	.cfi_def_cfa_offset 8
	ret
.L9:
	.cfi_restore_state
	leaq	.LC2(%rip), %rdi
	call	puts@PLT
	jmp	.L15
.L6:
	orl	$-1, %eax
	jmp	.L3
.L7:
	movq	%rbp, %rdi
	movl	%eax, 12(%rsp)
	call	free@PLT
	movl	12(%rsp), %eax
	jmp	.L3
.L29:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE52:
	.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.
Optimized Assembly Code:

user
```assembly
	.file	"temp.c"
	.text
	.p2align 4
	.globl	max
	.type	max, @function
max:
.LFB51:
	.cfi_startproc
	endbr64
	cmpl	%esi, %edi
	movl	%esi, %eax
	cmovge	%edi, %eax
	ret
	.cfi_endproc
.LFE51:
	.size	max, .-max
	.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:
.LFB52:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	leaq	.LC0(%rip), %rdi
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	subq	$40, %rsp
	.cfi_def_cfa_offset 80
	movq	%fs:40, %rax
	movq	%rax, 24(%rsp)
	xorl	%eax, %eax
	leaq	20(%rsp), %rsi
	call	__isoc99_scanf@PLT
	cmpl	$-1, %eax
	je	.L6
	movslq	20(%rsp), %rbx
	leal	1(%rbx), %edi
	movslq	%edi, %rdi
	call	malloc@PLT
	movq	%rax, %rbp
	testq	%rax, %rax
	je	.L6
	movb	$0, (%rax,%rbx)
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	cmpl	$-1, %eax
	je	.L7
	movzbl	0(%rbp), %eax
	leaq	1(%rbp), %rdx
	xorl	%ecx, %ecx
	xorl	%r12d, %r12d
	testb	%al, %al
	jne	.L12
	jmp	.L9
	.p2align 4,,10
	.p2align 3
.L10:
	cmpb	$87, %al
	sete	%al
	addq	$1, %rdx
	movzbl	%al, %eax
	addl	%eax, %ecx
	movzbl	-1(%rdx), %eax
	testb	%al, %al
	je	.L28
.L12:
	cmpb	$82, %al
	jne	.L10
	movzbl	(%rdx), %eax
	addq	$1, %rdx
	addl	$1, %r12d
	testb	%al, %al
	jne	.L12
.L28:
	testl	%r12d, %r12d
	je	.L9
	testl	%ecx, %ecx
	sete	%al
	cmpl	%ecx, %r12d
	cmovl	%ecx, %r12d
	xorl	%r13d, %r13d
	testb	%al, %al
	jne	.L9
	.p2align 4,,10
	.p2align 3
.L17:
	movl	$87, %esi
	movq	%rbp, %rdi
	call	strchr@PLT
	movl	$82, %esi
	movq	%rbp, %rdi
	movq	%rax, %rbx
	call	strrchr@PLT
	cmpq	%rax, %rbx
	ja	.L16
	addl	$1, %r13d
	movb	$82, (%rbx)
	movb	$87, (%rax)
	cmpl	%r13d, %r12d
	jne	.L17
.L16:
	movl	%r13d, %edx
	leaq	.LC3(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L15:
	movq	%rbp, %rdi
	call	free@PLT
	xorl	%eax, %eax
.L3:
	movq	24(%rsp), %rdx
	subq	%fs:40, %rdx
	jne	.L29
	addq	$40, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 40
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%rbp
	.cfi_def_cfa_offset 24
	popq	%r12
	.cfi_def_cfa_offset 16
	popq	%r13
	.cfi_def_cfa_offset 8
	ret
.L9:
	.cfi_restore_state
	leaq	.LC2(%rip), %rdi
	call	puts@PLT
	jmp	.L15
.L6:
	orl	$-1, %eax
	jmp	.L3
.L7:
	movq	%rbp, %rdi
	movl	%eax, 12(%rsp)
	call	free@PLT
	movl	12(%rsp), %eax
	jmp	.L3
.L29:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE52:
	.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
```assembly
	.file	"temp.c"
	.text
	.p2align 4
	.globl	max
	.type	max, @function
max:
.LFB51:
	.cfi_startproc
	endbr64
	cmpl	%esi, %edi
	movl	%esi, %eax
	cmovge	%edi, %eax
	ret
	.cfi_endproc
.LFE51:
	.size	max, .-max
	.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:
.LFB52:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	leaq	.LC0(%rip), %rdi
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	subq	$40, %rsp
	.cfi_def_cfa_offset 80
	movq	%fs:40, %rax
	movq	%rax, 24(%rsp)
	xorl	%eax, %eax
	leaq	20(%rsp), %rsi
	call	__isoc99_scanf@PLT
	cmpl	$-1, %eax
	je	.L6
	movslq	20(%rsp), %rbx
	leal	1(%rbx), %edi
	movslq	%edi, %rdi
	call	malloc@PLT
	movq	%rax, %rbp
	testq	%rax, %rax
	je	.L6
	movb	$0, (%rax,%rbx)
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	cmpl	$-1, %eax
	je	.L7
	movzbl	0(%rbp), %eax
	leaq	1(%rbp), %rdx
	xorl	%ecx, %ecx
	xorl	%r12d, %r12d
	testb	%al, %al
	jne	.L12
	jmp	.L9
	.p2align 4,,10
	.p2align 3
.L10:
	cmpb	$87, %al
	sete	%al
	addq	$1, %rdx
	movzbl	%al, %eax
	addl	%eax, %ecx
	movzbl	-1(%rdx), %eax
	testb	%al, %al
	je	.L28
.L12:
	cmpb	$82, %al
	jne	.L10
	movzbl	(%rdx), %eax
	addq	$1, %rdx
	addl	$1, %r12d
	testb	%al, %al
	jne	.L12
.L28:
	testl	%r12d, %r12d
	je	.L9
	testl	%ecx, %ecx
	sete	%al
	cmpl	%ecx, %r12d
	cmovl	%ecx, %r12d
	xorl	%r13d, %r13d
	testb	%al, %al
	jne	.L9
	.p2align 4,,10
	.p2align 3
.L17:
	movl	$87, %esi
	movq	%rbp, %rdi
	call	strchr@PLT
	movl	$82, %esi
	movq	%rbp, %rdi
	movq	%rax, %rbx
	call	strrchr@PLT
	cmpq	%rax, %rbx
	ja	.L16
	addl	$1, %r13d
	movb	$82, (%rbx)
	movb	$87, (%rax)
	cmpl	%r13d, %r12d
	jne	.L17
.L16:
	movl	%r13d, %edx
	leaq	.LC3(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L15:
	movq	%rbp, %rdi
	call	free@PLT
	xorl	%eax, %eax
.L3:
	movq	24(%rsp), %rdx
	subq	%fs:40, %rdx
	jne	.L29
	addq	$40, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 40
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%rbp
	.cfi_def_cfa_offset 24
	popq	%r12
	.cfi_def_cfa_offset 16
	popq	%r13
	.cfi_def_cfa_offset 8
	ret
.L9:
	.cfi_restore_state
	leaq	.LC2(%rip), %rdi
	call	puts@PLT
	jmp	.L15
.L6:
	orl	$-1, %eax
	jmp	.L3
.L7:
	movq	%rbp, %rdi
	movl	%eax, 12(%rsp)
	call	free@PLT
	movl	12(%rsp), %eax
	jmp	.L3
.L29:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE52:
	.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:
```
```c
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int	max(int a, int b)
{
  if (a > b)
    return (a);
  else
    return (b);
}

int	main(void)
{
  int	n;
  char	*s;
  int	i;
  int	nR;
  int	nW;
  char	*cR;
  char	*cW;
  char	*tmp;
  int	count;
  int	m;
  
  if (scanf("%d", &n) == EOF)
    return (-1);
  if (!(s = (char *)malloc((n + 1) * sizeof(char))))
    return (-1);
  s[n] = '\0';
  if (scanf("%s", s) == EOF)
  {
    free(s);
    return (-1);
  }
  i = 0;
  nR = 0;
  nW = 0;
  while (s[i])
  {
    if (s[i] == 'R')
      nR++;
    else if (s[i] == 'W')
      nW++;
    i++;
  }
  if (nR == 0 || nW == 0)
    printf("0\n");
  else
  {
    m = max(nR, nW);
    count = 0;
    while (count < m)
    {
	  	cW = strchr(s, 'W');
      	cR = strrchr(s, 'R');
      	if (cW > cR)
          break ;
      	else
        {
          *cW = 'R';
          *cR = 'W';
          count++;
        }
    }
    printf("%d\n", count);
  }
  free(s);
  return (0);
}```
Given the following C code, your task is to generate highly optimized x86-64 assembly code.
C Code:

```c
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int	max(int a, int b)
{
  if (a > b)
    return (a);
  else
    return (b);
}

int	main(void)
{
  int	n;
  char	*s;
  int	i;
  int	nR;
  int	nW;
  char	*cR;
  char	*cW;
  char	*tmp;
  int	count;
  int	m;
  
  if (scanf("%d", &n) == EOF)
    return (-1);
  if (!(s = (char *)malloc((n + 1) * sizeof(char))))
    return (-1);
  s[n] = '\0';
  if (scanf("%s", s) == EOF)
  {
    free(s);
    return (-1);
  }
  i = 0;
  nR = 0;
  nW = 0;
  while (s[i])
  {
    if (s[i] == 'R')
      nR++;
    else if (s[i] == 'W')
      nW++;
    i++;
  }
  if (nR == 0 || nW == 0)
    printf("0\n");
  else
  {
    m = max(nR, nW);
    count = 0;
    while (count < m)
    {
	  	cW = strchr(s, 'W');
      	cR = strrchr(s, 'R');
      	if (cW > cR)
          break ;
      	else
        {
          *cW = 'R';
          *cR = 'W';
          count++;
        }
    }
    printf("%d\n", count);
  }
  free(s);
  return (0);
}```

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.
Optimized Assembly Code:

8
RRWRWWRW
 2
RQ
 8
RRWWWRRW
 8
WRWWWRRR
 8
WWWWRRRR
 8
RRWRVWRW
 4
RRWW
 4
RWWR
 2
RS
 4
RRVW

1
 0
 2
 3
 4
 1
 0
 1
 0
 0

Given the following C code and assembly code, your task is to generate highly optimized x86-64 assembly code.
C Code:

```c
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int	max(int a, int b)
{
  if (a > b)
    return (a);
  else
    return (b);
}

int	main(void)
{
  int	n;
  char	*s;
  int	i;
  int	nR;
  int	nW;
  char	*cR;
  char	*cW;
  char	*tmp;
  int	count;
  int	m;
  
  if (scanf("%d", &n) == EOF)
    return (-1);
  if (!(s = (char *)malloc((n + 1) * sizeof(char))))
    return (-1);
  s[n] = '\0';
  if (scanf("%s", s) == EOF)
  {
    free(s);
    return (-1);
  }
  i = 0;
  nR = 0;
  nW = 0;
  while (s[i])
  {
    if (s[i] == 'R')
      nR++;
    else if (s[i] == 'W')
      nW++;
    i++;
  }
  if (nR == 0 || nW == 0)
    printf("0\n");
  else
  {
    m = max(nR, nW);
    count = 0;
    while (count < m)
    {
	  	cW = strchr(s, 'W');
      	cR = strrchr(s, 'R');
      	if (cW > cR)
          break ;
      	else
        {
          *cW = 'R';
          *cR = 'W';
          count++;
        }
    }
    printf("%d\n", count);
  }
  free(s);
  return (0);
}```

Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.p2align 4
	.globl	max
	.type	max, @function
max:
.LFB51:
	.cfi_startproc
	endbr64
	cmpl	%esi, %edi
	movl	%esi, %eax
	cmovge	%edi, %eax
	ret
	.cfi_endproc
.LFE51:
	.size	max, .-max
	.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:
.LFB52:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	leaq	.LC0(%rip), %rdi
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	subq	$40, %rsp
	.cfi_def_cfa_offset 80
	movq	%fs:40, %rax
	movq	%rax, 24(%rsp)
	xorl	%eax, %eax
	leaq	20(%rsp), %rsi
	call	__isoc99_scanf@PLT
	cmpl	$-1, %eax
	je	.L6
	movslq	20(%rsp), %rbx
	leal	1(%rbx), %edi
	movslq	%edi, %rdi
	call	malloc@PLT
	movq	%rax, %rbp
	testq	%rax, %rax
	je	.L6
	movb	$0, (%rax,%rbx)
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	cmpl	$-1, %eax
	je	.L7
	movzbl	0(%rbp), %eax
	leaq	1(%rbp), %rdx
	xorl	%ecx, %ecx
	xorl	%r12d, %r12d
	testb	%al, %al
	jne	.L12
	jmp	.L9
	.p2align 4,,10
	.p2align 3
.L10:
	cmpb	$87, %al
	sete	%al
	addq	$1, %rdx
	movzbl	%al, %eax
	addl	%eax, %ecx
	movzbl	-1(%rdx), %eax
	testb	%al, %al
	je	.L28
.L12:
	cmpb	$82, %al
	jne	.L10
	movzbl	(%rdx), %eax
	addq	$1, %rdx
	addl	$1, %r12d
	testb	%al, %al
	jne	.L12
.L28:
	testl	%r12d, %r12d
	je	.L9
	testl	%ecx, %ecx
	sete	%al
	cmpl	%ecx, %r12d
	cmovl	%ecx, %r12d
	xorl	%r13d, %r13d
	testb	%al, %al
	jne	.L9
	.p2align 4,,10
	.p2align 3
.L17:
	movl	$87, %esi
	movq	%rbp, %rdi
	call	strchr@PLT
	movl	$82, %esi
	movq	%rbp, %rdi
	movq	%rax, %rbx
	call	strrchr@PLT
	cmpq	%rax, %rbx
	ja	.L16
	addl	$1, %r13d
	movb	$82, (%rbx)
	movb	$87, (%rax)
	cmpl	%r13d, %r12d
	jne	.L17
.L16:
	movl	%r13d, %edx
	leaq	.LC3(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L15:
	movq	%rbp, %rdi
	call	free@PLT
	xorl	%eax, %eax
.L3:
	movq	24(%rsp), %rdx
	subq	%fs:40, %rdx
	jne	.L29
	addq	$40, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 40
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%rbp
	.cfi_def_cfa_offset 24
	popq	%r12
	.cfi_def_cfa_offset 16
	popq	%r13
	.cfi_def_cfa_offset 8
	ret
.L9:
	.cfi_restore_state
	leaq	.LC2(%rip), %rdi
	call	puts@PLT
	jmp	.L15
.L6:
	orl	$-1, %eax
	jmp	.L3
.L7:
	movq	%rbp, %rdi
	movl	%eax, 12(%rsp)
	call	free@PLT
	movl	12(%rsp), %eax
	jmp	.L3
.L29:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE52:
	.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.
Optimized Assembly Code:

train
```assembly
	.file	"temp.c"
	.text
	.p2align 4
	.globl	max
	.type	max, @function
max:
.LFB51:
	.cfi_startproc
	endbr64
	cmpl	%esi, %edi
	movl	%esi, %eax
	cmovge	%edi, %eax
	ret
	.cfi_endproc
.LFE51:
	.size	max, .-max
	.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:
.LFB52:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	leaq	.LC0(%rip), %rdi
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	subq	$40, %rsp
	.cfi_def_cfa_offset 80
	movq	%fs:40, %rax
	movq	%rax, 24(%rsp)
	xorl	%eax, %eax
	leaq	20(%rsp), %rsi
	call	__isoc99_scanf@PLT
	cmpl	$-1, %eax
	je	.L6
	movslq	20(%rsp), %rbx
	leal	1(%rbx), %edi
	movslq	%edi, %rdi
	call	malloc@PLT
	movq	%rax, %rbp
	testq	%rax, %rax
	je	.L6
	movb	$0, (%rax,%rbx)
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	cmpl	$-1, %eax
	je	.L7
	movzbl	0(%rbp), %eax
	leaq	1(%rbp), %rdx
	xorl	%ecx, %ecx
	xorl	%r12d, %r12d
	testb	%al, %al
	jne	.L12
	jmp	.L9
	.p2align 4,,10
	.p2align 3
.L10:
	cmpb	$87, %al
	sete	%al
	addq	$1, %rdx
	movzbl	%al, %eax
	addl	%eax, %ecx
	movzbl	-1(%rdx), %eax
	testb	%al, %al
	je	.L28
.L12:
	cmpb	$82, %al
	jne	.L10
	movzbl	(%rdx), %eax
	addq	$1, %rdx
	addl	$1, %r12d
	testb	%al, %al
	jne	.L12
.L28:
	testl	%r12d, %r12d
	je	.L9
	testl	%ecx, %ecx
	sete	%al
	cmpl	%ecx, %r12d
	cmovl	%ecx, %r12d
	xorl	%r13d, %r13d
	testb	%al, %al
	jne	.L9
	.p2align 4,,10
	.p2align 3
.L17:
	movl	$87, %esi
	movq	%rbp, %rdi
	call	strchr@PLT
	movl	$82, %esi
	movq	%rbp, %rdi
	movq	%rax, %rbx
	call	strrchr@PLT
	cmpq	%rax, %rbx
	ja	.L16
	addl	$1, %r13d
	movb	$82, (%rbx)
	movb	$87, (%rax)
	cmpl	%r13d, %r12d
	jne	.L17
.L16:
	movl	%r13d, %edx
	leaq	.LC3(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L15:
	movq	%rbp, %rdi
	call	free@PLT
	xorl	%eax, %eax
.L3:
	movq	24(%rsp), %rdx
	subq	%fs:40, %rdx
	jne	.L29
	addq	$40, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 40
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%rbp
	.cfi_def_cfa_offset 24
	popq	%r12
	.cfi_def_cfa_offset 16
	popq	%r13
	.cfi_def_cfa_offset 8
	ret
.L9:
	.cfi_restore_state
	leaq	.LC2(%rip), %rdi
	call	puts@PLT
	jmp	.L15
.L6:
	orl	$-1, %eax
	jmp	.L3
.L7:
	movq	%rbp, %rdi
	movl	%eax, 12(%rsp)
	call	free@PLT
	movl	12(%rsp), %eax
	jmp	.L3
.L29:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE52:
	.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:
```