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>

#define MAX(A,B) \
  ( (A) > (B) ? (A) : (B) );

static
unsigned int d[ 10000 ];
static
int bc[ 1024 ];
static
int R, C;

static
int dfs (
  int n
  )
{
  int res;
  int i, j;

  if ( n >= R )
  {
    res = 0;
    
    for ( i = 0; i < C; ++i )
    {
      int t = bc[ d[ i ] ];
      res += MAX( t, R - t );
    }
  }
  else
  {
    res = dfs ( n + 1 );

    for ( i = 0; i < C; ++i )
    {
      d[ i ] = d[ i ] ^ ( 1 << n );
    }
    res = MAX( res, dfs ( n + 1 ) );
    for ( i = 0; i < C; ++i )
    {
      d[ i ] = d[ i ] ^ ( 1 << n );
    }
  }

  return ( res );
}

/** Application main entry point. */
int main (
  int     argc,
  char  * argv[ ]
  )
{
  int i, j;

  for ( i = 0; i < 1024; ++i )
  {
    bc[ i ] = 0;
    for ( j = 1; j <= i; j <<= 1 )
    {
      bc[ i ] += !!( i & j );
    }
  }

  for ( ; ; )
  {
    scanf ( "%d%d", &R, &C );
    if ( !( R | C ) ) break ;

    memset ( d, 0, sizeof ( d ) );
    for ( j = 0; j < R; ++j )
    for ( i = 0; i < C; ++i )
    {
      int t;

      scanf ( "%d", &t );
      d[ i ] |= ( t << j );
    }

    printf ( "%d\n", dfs ( 0 ) );
  }

  return ( 0 );
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.local	d
	.comm	d,40000,32
	.local	bc
	.comm	bc,4096,32
	.local	R
	.comm	R,4,4
	.local	C
	.comm	C,4,4
	.type	dfs, @function
dfs:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$32, %rsp
	movl	%edi, -20(%rbp)
	movl	R(%rip), %eax
	cmpl	%eax, -20(%rbp)
	jl	.L2
	movl	$0, -12(%rbp)
	movl	$0, -8(%rbp)
	jmp	.L3
.L4:
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	d(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, %eax
	leaq	0(,%rax,4), %rdx
	leaq	bc(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -4(%rbp)
	movl	R(%rip), %eax
	subl	-4(%rbp), %eax
	movl	%eax, %edx
	movl	-4(%rbp), %eax
	cmpl	%eax, %edx
	cmovge	%edx, %eax
	addl	%eax, -12(%rbp)
	addl	$1, -8(%rbp)
.L3:
	movl	C(%rip), %eax
	cmpl	%eax, -8(%rbp)
	jl	.L4
	jmp	.L5
.L2:
	movl	-20(%rbp), %eax
	addl	$1, %eax
	movl	%eax, %edi
	call	dfs
	movl	%eax, -12(%rbp)
	movl	$0, -8(%rbp)
	jmp	.L6
.L7:
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	d(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-20(%rbp), %eax
	movl	$1, %esi
	movl	%eax, %ecx
	sall	%cl, %esi
	movl	%esi, %eax
	movl	%edx, %ecx
	xorl	%eax, %ecx
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	d(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	addl	$1, -8(%rbp)
.L6:
	movl	C(%rip), %eax
	cmpl	%eax, -8(%rbp)
	jl	.L7
	movl	-20(%rbp), %eax
	addl	$1, %eax
	movl	%eax, %edi
	call	dfs
	cmpl	%eax, -12(%rbp)
	jg	.L8
	movl	-20(%rbp), %eax
	addl	$1, %eax
	movl	%eax, %edi
	call	dfs
	jmp	.L9
.L8:
	movl	-12(%rbp), %eax
.L9:
	movl	%eax, -12(%rbp)
	movl	$0, -8(%rbp)
	jmp	.L10
.L11:
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	d(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-20(%rbp), %eax
	movl	$1, %esi
	movl	%eax, %ecx
	sall	%cl, %esi
	movl	%esi, %eax
	movl	%edx, %ecx
	xorl	%eax, %ecx
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	d(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	addl	$1, -8(%rbp)
.L10:
	movl	C(%rip), %eax
	cmpl	%eax, -8(%rbp)
	jl	.L11
.L5:
	movl	-12(%rbp), %eax
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	dfs, .-dfs
	.section	.rodata
.LC0:
	.string	"%d%d"
.LC1:
	.string	"%d"
.LC2:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB1:
	.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	%rsi, -48(%rbp)
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	$0, -16(%rbp)
	jmp	.L14
.L17:
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	bc(%rip), %rax
	movl	$0, (%rdx,%rax)
	movl	$1, -12(%rbp)
	jmp	.L15
.L16:
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	bc(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-16(%rbp), %eax
	andl	-12(%rbp), %eax
	testl	%eax, %eax
	setne	%al
	movzbl	%al, %eax
	leal	(%rdx,%rax), %ecx
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	bc(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	sall	-12(%rbp)
.L15:
	movl	-12(%rbp), %eax
	cmpl	-16(%rbp), %eax
	jle	.L16
	addl	$1, -16(%rbp)
.L14:
	cmpl	$1023, -16(%rbp)
	jle	.L17
.L24:
	leaq	C(%rip), %rax
	movq	%rax, %rdx
	leaq	R(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	R(%rip), %edx
	movl	C(%rip), %eax
	orl	%edx, %eax
	testl	%eax, %eax
	je	.L28
	movl	$40000, %edx
	movl	$0, %esi
	leaq	d(%rip), %rax
	movq	%rax, %rdi
	call	memset@PLT
	movl	$0, -12(%rbp)
	jmp	.L20
.L23:
	movl	$0, -16(%rbp)
	jmp	.L21
.L22:
	leaq	-20(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	d(%rip), %rax
	movl	(%rdx,%rax), %esi
	movl	-20(%rbp), %edx
	movl	-12(%rbp), %eax
	movl	%eax, %ecx
	sall	%cl, %edx
	movl	%edx, %eax
	movl	%esi, %ecx
	orl	%eax, %ecx
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	d(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	addl	$1, -16(%rbp)
.L21:
	movl	C(%rip), %eax
	cmpl	%eax, -16(%rbp)
	jl	.L22
	addl	$1, -12(%rbp)
.L20:
	movl	R(%rip), %eax
	cmpl	%eax, -12(%rbp)
	jl	.L23
	movl	$0, %edi
	call	dfs
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L24
.L28:
	nop
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L26
	call	__stack_chk_fail@PLT
.L26:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.size	main, .-main
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:
```

Only output the optimized assembly code. Do not include any other text. Do not write any comments in the assembly code. Wrap the assembly code in ```assembly``` tags.
user
	.file	"temp.c"
	.text
	.p2align 4
	.type	dfs, @function
dfs:
.LFB35:
	.cfi_startproc
	movl	R(%rip), %esi
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	cmpl	%edi, %esi
	jg	.L2
	movl	C(%rip), %eax
	testl	%eax, %eax
	jle	.L14
	leaq	d(%rip), %rdx
	leal	-1(%rax), %ecx
	xorl	%r12d, %r12d
	leaq	4(%rdx), %rax
	leaq	bc(%rip), %rdi
	leaq	(%rax,%rcx,4), %r8
	.p2align 4,,10
	.p2align 3
.L4:
	movl	(%rdx), %eax
	movl	(%rdi,%rax,4), %ecx
	movl	%esi, %eax
	subl	%ecx, %eax
	cmpl	%ecx, %eax
	cmovl	%ecx, %eax
	addq	$4, %rdx
	addl	%eax, %r12d
	cmpq	%rdx, %r8
	jne	.L4
.L1:
	movl	%r12d, %eax
	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
	leal	1(%rdi), %ebp
	movl	%edi, %ebx
	movl	%ebp, %edi
	call	dfs
	movl	C(%rip), %esi
	movl	%eax, %r12d
	testl	%esi, %esi
	jle	.L5
	movl	$1, %edi
	movl	%ebx, %ecx
	leal	-1(%rsi), %eax
	sall	%cl, %edi
	cmpl	$2, %eax
	jbe	.L15
	movl	%esi, %ecx
	leaq	d(%rip), %rdx
	movd	%edi, %xmm2
	shrl	$2, %ecx
	leaq	16(%rdx), %r8
	pshufd	$0, %xmm2, %xmm1
	movq	%rdx, %rax
	subl	$1, %ecx
	salq	$4, %rcx
	addq	%r8, %rcx
	.p2align 4,,10
	.p2align 3
.L7:
	movdqa	(%rax), %xmm0
	addq	$16, %rax
	pxor	%xmm1, %xmm0
	movaps	%xmm0, -16(%rax)
	cmpq	%rcx, %rax
	jne	.L7
	movl	%esi, %eax
	andl	$-4, %eax
	testb	$3, %sil
	je	.L5
.L6:
	movslq	%eax, %rcx
	xorl	%edi, (%rdx,%rcx,4)
	leal	1(%rax), %ecx
	cmpl	%ecx, %esi
	jle	.L5
	movslq	%ecx, %rcx
	addl	$2, %eax
	xorl	%edi, (%rdx,%rcx,4)
	cmpl	%eax, %esi
	jle	.L5
	cltq
	xorl	%edi, (%rdx,%rax,4)
.L5:
	movl	%ebp, %edi
	call	dfs
	cmpl	%r12d, %eax
	jge	.L22
.L9:
	movl	C(%rip), %esi
	testl	%esi, %esi
	jle	.L1
	movl	$1, %edi
	movl	%ebx, %ecx
	leal	-1(%rsi), %eax
	sall	%cl, %edi
	cmpl	$2, %eax
	jbe	.L16
	movl	%esi, %ecx
	leaq	d(%rip), %rdx
	movd	%edi, %xmm3
	shrl	$2, %ecx
	leaq	16(%rdx), %r8
	pshufd	$0, %xmm3, %xmm1
	movq	%rdx, %rax
	subl	$1, %ecx
	salq	$4, %rcx
	addq	%r8, %rcx
	.p2align 4,,10
	.p2align 3
.L11:
	movdqa	(%rax), %xmm0
	addq	$16, %rax
	pxor	%xmm1, %xmm0
	movaps	%xmm0, -16(%rax)
	cmpq	%rcx, %rax
	jne	.L11
	movl	%esi, %eax
	andl	$-4, %eax
	testb	$3, %sil
	je	.L1
.L10:
	movslq	%eax, %rcx
	xorl	%edi, (%rdx,%rcx,4)
	leal	1(%rax), %ecx
	cmpl	%ecx, %esi
	jle	.L1
	movslq	%ecx, %rcx
	addl	$2, %eax
	xorl	%edi, (%rdx,%rcx,4)
	cmpl	%eax, %esi
	jle	.L1
	cltq
	xorl	%edi, (%rdx,%rax,4)
	movl	%r12d, %eax
	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
.L22:
	.cfi_restore_state
	movl	%ebp, %edi
	call	dfs
	movl	%eax, %r12d
	jmp	.L9
	.p2align 4,,10
	.p2align 3
.L14:
	xorl	%r12d, %r12d
	jmp	.L1
.L16:
	xorl	%eax, %eax
	leaq	d(%rip), %rdx
	jmp	.L10
.L15:
	xorl	%eax, %eax
	leaq	d(%rip), %rdx
	jmp	.L6
	.cfi_endproc
.LFE35:
	.size	dfs, .-dfs
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d%d"
.LC1:
	.string	"%d"
.LC3:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB36:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	movl	$1, %r8d
	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	$24, %rsp
	.cfi_def_cfa_offset 80
	movq	%fs:40, %rax
	movq	%rax, 8(%rsp)
	xorl	%eax, %eax
	movl	$0, bc(%rip)
	.p2align 4,,10
	.p2align 3
.L25:
	movl	%r8d, %edi
	movl	%r8d, %esi
	xorl	%edx, %edx
	movl	$1, %eax
	.p2align 4,,10
	.p2align 3
.L24:
	movl	%edi, %ecx
	andl	%eax, %ecx
	cmpl	$1, %ecx
	sbbl	$-1, %edx
	addl	%eax, %eax
	cmpl	%esi, %eax
	jle	.L24
	leaq	bc(%rip), %rax
	movl	%edx, (%rax,%r8,4)
	addq	$1, %r8
	cmpq	$1024, %r8
	jne	.L25
	leaq	.LC1(%rip), %r12
	.p2align 4,,10
	.p2align 3
.L45:
	xorl	%eax, %eax
	leaq	C(%rip), %rdx
	leaq	R(%rip), %rsi
	leaq	.LC0(%rip), %rdi
	call	__isoc99_scanf@PLT
	movl	R(%rip), %ebp
	movl	C(%rip), %r15d
	movl	%ebp, %eax
	orl	%r15d, %eax
	je	.L26
	leaq	d(%rip), %r14
	movl	$40000, %edx
	xorl	%esi, %esi
	xorl	%ebx, %ebx
	movq	%r14, %rdi
	call	memset@PLT
	testl	%ebp, %ebp
	jle	.L28
	.p2align 4,,10
	.p2align 3
.L27:
	testl	%r15d, %r15d
	jle	.L31
	xorl	%r13d, %r13d
	leaq	4(%rsp), %rbp
	.p2align 4,,10
	.p2align 3
.L29:
	movq	%rbp, %rsi
	movq	%r12, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	4(%rsp), %eax
	movl	%ebx, %ecx
	movl	C(%rip), %r15d
	sall	%cl, %eax
	orl	%eax, (%r14,%r13,4)
	addq	$1, %r13
	cmpl	%r13d, %r15d
	jg	.L29
	movl	R(%rip), %ebp
	addl	$1, %ebx
	cmpl	%ebx, %ebp
	jg	.L27
	testl	%ebp, %ebp
	jg	.L31
.L28:
	testl	%r15d, %r15d
	jle	.L49
	leaq	d(%rip), %rdx
	leal	-1(%r15), %ecx
	xorl	%r9d, %r9d
	leaq	4(%rdx), %rax
	leaq	(%rax,%rcx,4), %rsi
	.p2align 4,,10
	.p2align 3
.L33:
	movl	(%rdx), %eax
	leaq	bc(%rip), %rbx
	movl	(%rbx,%rax,4), %ecx
	movl	%ebp, %eax
	subl	%ecx, %eax
	cmpl	%ecx, %eax
	cmovl	%ecx, %eax
	addq	$4, %rdx
	addl	%eax, %r9d
	cmpq	%rsi, %rdx
	jne	.L33
.L32:
	movl	%r9d, %edx
	leaq	.LC3(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L45
.L31:
	movl	$1, %edi
	call	dfs
	movl	C(%rip), %ecx
	movl	%eax, %r9d
	testl	%ecx, %ecx
	jle	.L40
	leal	-1(%rcx), %eax
	cmpl	$2, %eax
	jbe	.L50
	movl	%ecx, %edx
	leaq	d(%rip), %rax
	shrl	$2, %edx
	leaq	16(%rax), %rsi
	subl	$1, %edx
	salq	$4, %rdx
	addq	%rsi, %rdx
	.p2align 4,,10
	.p2align 3
.L38:
	movdqa	.LC2(%rip), %xmm0
	pxor	(%rax), %xmm0
	addq	$16, %rax
	movaps	%xmm0, -16(%rax)
	cmpq	%rdx, %rax
	jne	.L38
	movl	%ecx, %eax
	andl	$-4, %eax
	testb	$3, %cl
	je	.L40
.L37:
	movslq	%eax, %rdx
	xorl	$1, (%r14,%rdx,4)
	leal	1(%rax), %edx
	cmpl	%edx, %ecx
	jle	.L40
	movslq	%edx, %rdx
	addl	$2, %eax
	xorl	$1, (%r14,%rdx,4)
	cmpl	%eax, %ecx
	jle	.L40
	cltq
	xorl	$1, (%r14,%rax,4)
.L40:
	movl	$1, %edi
	call	dfs
	cmpl	%eax, %r9d
	jle	.L60
.L36:
	movl	C(%rip), %ecx
	testl	%ecx, %ecx
	jle	.L32
	leal	-1(%rcx), %eax
	cmpl	$2, %eax
	jbe	.L51
	movl	%ecx, %edx
	leaq	d(%rip), %rax
	shrl	$2, %edx
	leaq	16(%rax), %rsi
	subl	$1, %edx
	salq	$4, %rdx
	addq	%rsi, %rdx
	.p2align 4,,10
	.p2align 3
.L43:
	movdqa	.LC2(%rip), %xmm0
	pxor	(%rax), %xmm0
	addq	$16, %rax
	movaps	%xmm0, -16(%rax)
	cmpq	%rdx, %rax
	jne	.L43
	movl	%ecx, %eax
	andl	$-4, %eax
	testb	$3, %cl
	je	.L32
.L42:
	movslq	%eax, %rdx
	xorl	$1, (%r14,%rdx,4)
	leal	1(%rax), %edx
	cmpl	%edx, %ecx
	jle	.L32
	movslq	%edx, %rdx
	addl	$2, %eax
	xorl	$1, (%r14,%rdx,4)
	cmpl	%ecx, %eax
	jge	.L32
	cltq
	xorl	$1, (%r14,%rax,4)
	jmp	.L32
.L26:
	movq	8(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L61
	addq	$24, %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
.L60:
	.cfi_restore_state
	movl	$1, %edi
	call	dfs
	movl	%eax, %r9d
	jmp	.L36
.L49:
	xorl	%r9d, %r9d
	jmp	.L32
.L50:
	xorl	%eax, %eax
	jmp	.L37
.L51:
	xorl	%eax, %eax
	jmp	.L42
.L61:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE36:
	.size	main, .-main
	.local	C
	.comm	C,4,4
	.local	R
	.comm	R,4,4
	.local	bc
	.comm	bc,4096,32
	.local	d
	.comm	d,40000,32
	.section	.rodata.cst16,"aM",@progbits,16
	.align 16
.LC2:
	.long	1
	.long	1
	.long	1
	.long	1
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:

rule
	.file	"temp.c"
	.text
	.p2align 4
	.type	dfs, @function
dfs:
.LFB35:
	.cfi_startproc
	movl	R(%rip), %esi
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	cmpl	%edi, %esi
	jg	.L2
	movl	C(%rip), %eax
	testl	%eax, %eax
	jle	.L14
	leaq	d(%rip), %rdx
	leal	-1(%rax), %ecx
	xorl	%r12d, %r12d
	leaq	4(%rdx), %rax
	leaq	bc(%rip), %rdi
	leaq	(%rax,%rcx,4), %r8
	.p2align 4,,10
	.p2align 3
.L4:
	movl	(%rdx), %eax
	movl	(%rdi,%rax,4), %ecx
	movl	%esi, %eax
	subl	%ecx, %eax
	cmpl	%ecx, %eax
	cmovl	%ecx, %eax
	addq	$4, %rdx
	addl	%eax, %r12d
	cmpq	%rdx, %r8
	jne	.L4
.L1:
	movl	%r12d, %eax
	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
	leal	1(%rdi), %ebp
	movl	%edi, %ebx
	movl	%ebp, %edi
	call	dfs
	movl	C(%rip), %esi
	movl	%eax, %r12d
	testl	%esi, %esi
	jle	.L5
	movl	$1, %edi
	movl	%ebx, %ecx
	leal	-1(%rsi), %eax
	sall	%cl, %edi
	cmpl	$2, %eax
	jbe	.L15
	movl	%esi, %ecx
	leaq	d(%rip), %rdx
	movd	%edi, %xmm2
	shrl	$2, %ecx
	leaq	16(%rdx), %r8
	pshufd	$0, %xmm2, %xmm1
	movq	%rdx, %rax
	subl	$1, %ecx
	salq	$4, %rcx
	addq	%r8, %rcx
	.p2align 4,,10
	.p2align 3
.L7:
	movdqa	(%rax), %xmm0
	addq	$16, %rax
	pxor	%xmm1, %xmm0
	movaps	%xmm0, -16(%rax)
	cmpq	%rcx, %rax
	jne	.L7
	movl	%esi, %eax
	andl	$-4, %eax
	testb	$3, %sil
	je	.L5
.L6:
	movslq	%eax, %rcx
	xorl	%edi, (%rdx,%rcx,4)
	leal	1(%rax), %ecx
	cmpl	%ecx, %esi
	jle	.L5
	movslq	%ecx, %rcx
	addl	$2, %eax
	xorl	%edi, (%rdx,%rcx,4)
	cmpl	%eax, %esi
	jle	.L5
	cltq
	xorl	%edi, (%rdx,%rax,4)
.L5:
	movl	%ebp, %edi
	call	dfs
	cmpl	%r12d, %eax
	jge	.L22
.L9:
	movl	C(%rip), %esi
	testl	%esi, %esi
	jle	.L1
	movl	$1, %edi
	movl	%ebx, %ecx
	leal	-1(%rsi), %eax
	sall	%cl, %edi
	cmpl	$2, %eax
	jbe	.L16
	movl	%esi, %ecx
	leaq	d(%rip), %rdx
	movd	%edi, %xmm3
	shrl	$2, %ecx
	leaq	16(%rdx), %r8
	pshufd	$0, %xmm3, %xmm1
	movq	%rdx, %rax
	subl	$1, %ecx
	salq	$4, %rcx
	addq	%r8, %rcx
	.p2align 4,,10
	.p2align 3
.L11:
	movdqa	(%rax), %xmm0
	addq	$16, %rax
	pxor	%xmm1, %xmm0
	movaps	%xmm0, -16(%rax)
	cmpq	%rcx, %rax
	jne	.L11
	movl	%esi, %eax
	andl	$-4, %eax
	testb	$3, %sil
	je	.L1
.L10:
	movslq	%eax, %rcx
	xorl	%edi, (%rdx,%rcx,4)
	leal	1(%rax), %ecx
	cmpl	%ecx, %esi
	jle	.L1
	movslq	%ecx, %rcx
	addl	$2, %eax
	xorl	%edi, (%rdx,%rcx,4)
	cmpl	%eax, %esi
	jle	.L1
	cltq
	xorl	%edi, (%rdx,%rax,4)
	movl	%r12d, %eax
	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
.L22:
	.cfi_restore_state
	movl	%ebp, %edi
	call	dfs
	movl	%eax, %r12d
	jmp	.L9
	.p2align 4,,10
	.p2align 3
.L14:
	xorl	%r12d, %r12d
	jmp	.L1
.L16:
	xorl	%eax, %eax
	leaq	d(%rip), %rdx
	jmp	.L10
.L15:
	xorl	%eax, %eax
	leaq	d(%rip), %rdx
	jmp	.L6
	.cfi_endproc
.LFE35:
	.size	dfs, .-dfs
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d%d"
.LC1:
	.string	"%d"
.LC3:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB36:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	movl	$1, %r8d
	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	$24, %rsp
	.cfi_def_cfa_offset 80
	movq	%fs:40, %rax
	movq	%rax, 8(%rsp)
	xorl	%eax, %eax
	movl	$0, bc(%rip)
	.p2align 4,,10
	.p2align 3
.L25:
	movl	%r8d, %edi
	movl	%r8d, %esi
	xorl	%edx, %edx
	movl	$1, %eax
	.p2align 4,,10
	.p2align 3
.L24:
	movl	%edi, %ecx
	andl	%eax, %ecx
	cmpl	$1, %ecx
	sbbl	$-1, %edx
	addl	%eax, %eax
	cmpl	%esi, %eax
	jle	.L24
	leaq	bc(%rip), %rax
	movl	%edx, (%rax,%r8,4)
	addq	$1, %r8
	cmpq	$1024, %r8
	jne	.L25
	leaq	.LC1(%rip), %r12
	.p2align 4,,10
	.p2align 3
.L45:
	xorl	%eax, %eax
	leaq	C(%rip), %rdx
	leaq	R(%rip), %rsi
	leaq	.LC0(%rip), %rdi
	call	__isoc99_scanf@PLT
	movl	R(%rip), %ebp
	movl	C(%rip), %r15d
	movl	%ebp, %eax
	orl	%r15d, %eax
	je	.L26
	leaq	d(%rip), %r14
	movl	$40000, %edx
	xorl	%esi, %esi
	xorl	%ebx, %ebx
	movq	%r14, %rdi
	call	memset@PLT
	testl	%ebp, %ebp
	jle	.L28
	.p2align 4,,10
	.p2align 3
.L27:
	testl	%r15d, %r15d
	jle	.L31
	xorl	%r13d, %r13d
	leaq	4(%rsp), %rbp
	.p2align 4,,10
	.p2align 3
.L29:
	movq	%rbp, %rsi
	movq	%r12, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	4(%rsp), %eax
	movl	%ebx, %ecx
	movl	C(%rip), %r15d
	sall	%cl, %eax
	orl	%eax, (%r14,%r13,4)
	addq	$1, %r13
	cmpl	%r13d, %r15d
	jg	.L29
	movl	R(%rip), %ebp
	addl	$1, %ebx
	cmpl	%ebx, %ebp
	jg	.L27
	testl	%ebp, %ebp
	jg	.L31
.L28:
	testl	%r15d, %r15d
	jle	.L49
	leaq	d(%rip), %rdx
	leal	-1(%r15), %ecx
	xorl	%r9d, %r9d
	leaq	4(%rdx), %rax
	leaq	(%rax,%rcx,4), %rsi
	.p2align 4,,10
	.p2align 3
.L33:
	movl	(%rdx), %eax
	leaq	bc(%rip), %rbx
	movl	(%rbx,%rax,4), %ecx
	movl	%ebp, %eax
	subl	%ecx, %eax
	cmpl	%ecx, %eax
	cmovl	%ecx, %eax
	addq	$4, %rdx
	addl	%eax, %r9d
	cmpq	%rsi, %rdx
	jne	.L33
.L32:
	movl	%r9d, %edx
	leaq	.LC3(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L45
.L31:
	movl	$1, %edi
	call	dfs
	movl	C(%rip), %ecx
	movl	%eax, %r9d
	testl	%ecx, %ecx
	jle	.L40
	leal	-1(%rcx), %eax
	cmpl	$2, %eax
	jbe	.L50
	movl	%ecx, %edx
	leaq	d(%rip), %rax
	shrl	$2, %edx
	leaq	16(%rax), %rsi
	subl	$1, %edx
	salq	$4, %rdx
	addq	%rsi, %rdx
	.p2align 4,,10
	.p2align 3
.L38:
	movdqa	.LC2(%rip), %xmm0
	pxor	(%rax), %xmm0
	addq	$16, %rax
	movaps	%xmm0, -16(%rax)
	cmpq	%rdx, %rax
	jne	.L38
	movl	%ecx, %eax
	andl	$-4, %eax
	testb	$3, %cl
	je	.L40
.L37:
	movslq	%eax, %rdx
	xorl	$1, (%r14,%rdx,4)
	leal	1(%rax), %edx
	cmpl	%edx, %ecx
	jle	.L40
	movslq	%edx, %rdx
	addl	$2, %eax
	xorl	$1, (%r14,%rdx,4)
	cmpl	%eax, %ecx
	jle	.L40
	cltq
	xorl	$1, (%r14,%rax,4)
.L40:
	movl	$1, %edi
	call	dfs
	cmpl	%eax, %r9d
	jle	.L60
.L36:
	movl	C(%rip), %ecx
	testl	%ecx, %ecx
	jle	.L32
	leal	-1(%rcx), %eax
	cmpl	$2, %eax
	jbe	.L51
	movl	%ecx, %edx
	leaq	d(%rip), %rax
	shrl	$2, %edx
	leaq	16(%rax), %rsi
	subl	$1, %edx
	salq	$4, %rdx
	addq	%rsi, %rdx
	.p2align 4,,10
	.p2align 3
.L43:
	movdqa	.LC2(%rip), %xmm0
	pxor	(%rax), %xmm0
	addq	$16, %rax
	movaps	%xmm0, -16(%rax)
	cmpq	%rdx, %rax
	jne	.L43
	movl	%ecx, %eax
	andl	$-4, %eax
	testb	$3, %cl
	je	.L32
.L42:
	movslq	%eax, %rdx
	xorl	$1, (%r14,%rdx,4)
	leal	1(%rax), %edx
	cmpl	%edx, %ecx
	jle	.L32
	movslq	%edx, %rdx
	addl	$2, %eax
	xorl	$1, (%r14,%rdx,4)
	cmpl	%ecx, %eax
	jge	.L32
	cltq
	xorl	$1, (%r14,%rax,4)
	jmp	.L32
.L26:
	movq	8(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L61
	addq	$24, %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
.L60:
	.cfi_restore_state
	movl	$1, %edi
	call	dfs
	movl	%eax, %r9d
	jmp	.L36
.L49:
	xorl	%r9d, %r9d
	jmp	.L32
.L50:
	xorl	%eax, %eax
	jmp	.L37
.L51:
	xorl	%eax, %eax
	jmp	.L42
.L61:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE36:
	.size	main, .-main
	.local	C
	.comm	C,4,4
	.local	R
	.comm	R,4,4
	.local	bc
	.comm	bc,4096,32
	.local	d
	.comm	d,40000,32
	.section	.rodata.cst16,"aM",@progbits,16
	.align 16
.LC2:
	.long	1
	.long	1
	.long	1
	.long	1
	.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>

#define MAX(A,B) \
  ( (A) > (B) ? (A) : (B) );

static
unsigned int d[ 10000 ];
static
int bc[ 1024 ];
static
int R, C;

static
int dfs (
  int n
  )
{
  int res;
  int i, j;

  if ( n >= R )
  {
    res = 0;
    
    for ( i = 0; i < C; ++i )
    {
      int t = bc[ d[ i ] ];
      res += MAX( t, R - t );
    }
  }
  else
  {
    res = dfs ( n + 1 );

    for ( i = 0; i < C; ++i )
    {
      d[ i ] = d[ i ] ^ ( 1 << n );
    }
    res = MAX( res, dfs ( n + 1 ) );
    for ( i = 0; i < C; ++i )
    {
      d[ i ] = d[ i ] ^ ( 1 << n );
    }
  }

  return ( res );
}

/** Application main entry point. */
int main (
  int     argc,
  char  * argv[ ]
  )
{
  int i, j;

  for ( i = 0; i < 1024; ++i )
  {
    bc[ i ] = 0;
    for ( j = 1; j <= i; j <<= 1 )
    {
      bc[ i ] += !!( i & j );
    }
  }

  for ( ; ; )
  {
    scanf ( "%d%d", &R, &C );
    if ( !( R | C ) ) break ;

    memset ( d, 0, sizeof ( d ) );
    for ( j = 0; j < R; ++j )
    for ( i = 0; i < C; ++i )
    {
      int t;

      scanf ( "%d", &t );
      d[ i ] |= ( t << j );
    }

    printf ( "%d\n", dfs ( 0 ) );
  }

  return ( 0 );
}
2 5
0 1 0 1 0
1 0 0 0 1
3 6
1 0 1 0 1 0
1 1 1 0 1 0
1 0 1 1 0 1
0 0
 2 5
0 1 1 1 0
1 0 0 0 1
3 6
1 0 0 0 1 0
1 1 1 0 1 0
1 0 1 1 0 1
0 0
 2 5
0 1 0 1 0
1 0 0 0 1
3 6
1 0 0 0 1 1
1 1 1 0 1 0
1 0 1 1 0 1
0 0
 2 5
1 1 1 1 0
1 0 0 1 1
3 6
1 0 0 0 1 0
0 1 1 0 1 0
1 0 1 1 0 1
0 0
 2 5
0 1 0 1 0
1 0 0 0 1
3 6
1 0 1 0 1 0
1 1 1 0 1 0
1 0 1 0 0 0
0 0
 2 5
0 1 0 1 0
1 0 0 0 1
3 6
1 0 1 0 1 0
1 0 1 0 1 0
1 0 1 0 0 0
0 0
 2 5
0 1 1 1 0
0 0 0 1 1
3 6
1 1 0 0 1 0
0 0 1 0 1 0
1 0 1 0 0 1
0 0
 2 5
1 1 1 1 0
0 0 0 0 1
3 6
1 0 0 0 0 1
0 1 1 0 1 0
1 0 1 1 0 1
0 0
 2 5
1 1 1 1 0
1 0 1 0 1
3 6
1 0 0 0 0 1
0 1 1 0 1 0
1 0 1 1 0 1
0 0
 2 5
1 1 1 1 0
0 0 0 0 1
3 6
1 0 0 0 1 0
0 1 1 0 1 1
1 0 1 1 0 1
0 0

9
15
 10
15
 9
14
 8
15
 9
16
 9
17
 8
14
 10
16
 8
16
 10
14

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>

#define MAX(A,B) \
  ( (A) > (B) ? (A) : (B) );

static
unsigned int d[ 10000 ];
static
int bc[ 1024 ];
static
int R, C;

static
int dfs (
  int n
  )
{
  int res;
  int i, j;

  if ( n >= R )
  {
    res = 0;
    
    for ( i = 0; i < C; ++i )
    {
      int t = bc[ d[ i ] ];
      res += MAX( t, R - t );
    }
  }
  else
  {
    res = dfs ( n + 1 );

    for ( i = 0; i < C; ++i )
    {
      d[ i ] = d[ i ] ^ ( 1 << n );
    }
    res = MAX( res, dfs ( n + 1 ) );
    for ( i = 0; i < C; ++i )
    {
      d[ i ] = d[ i ] ^ ( 1 << n );
    }
  }

  return ( res );
}

/** Application main entry point. */
int main (
  int     argc,
  char  * argv[ ]
  )
{
  int i, j;

  for ( i = 0; i < 1024; ++i )
  {
    bc[ i ] = 0;
    for ( j = 1; j <= i; j <<= 1 )
    {
      bc[ i ] += !!( i & j );
    }
  }

  for ( ; ; )
  {
    scanf ( "%d%d", &R, &C );
    if ( !( R | C ) ) break ;

    memset ( d, 0, sizeof ( d ) );
    for ( j = 0; j < R; ++j )
    for ( i = 0; i < C; ++i )
    {
      int t;

      scanf ( "%d", &t );
      d[ i ] |= ( t << j );
    }

    printf ( "%d\n", dfs ( 0 ) );
  }

  return ( 0 );
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.local	d
	.comm	d,40000,32
	.local	bc
	.comm	bc,4096,32
	.local	R
	.comm	R,4,4
	.local	C
	.comm	C,4,4
	.type	dfs, @function
dfs:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$32, %rsp
	movl	%edi, -20(%rbp)
	movl	R(%rip), %eax
	cmpl	%eax, -20(%rbp)
	jl	.L2
	movl	$0, -12(%rbp)
	movl	$0, -8(%rbp)
	jmp	.L3
.L4:
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	d(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, %eax
	leaq	0(,%rax,4), %rdx
	leaq	bc(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -4(%rbp)
	movl	R(%rip), %eax
	subl	-4(%rbp), %eax
	movl	%eax, %edx
	movl	-4(%rbp), %eax
	cmpl	%eax, %edx
	cmovge	%edx, %eax
	addl	%eax, -12(%rbp)
	addl	$1, -8(%rbp)
.L3:
	movl	C(%rip), %eax
	cmpl	%eax, -8(%rbp)
	jl	.L4
	jmp	.L5
.L2:
	movl	-20(%rbp), %eax
	addl	$1, %eax
	movl	%eax, %edi
	call	dfs
	movl	%eax, -12(%rbp)
	movl	$0, -8(%rbp)
	jmp	.L6
.L7:
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	d(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-20(%rbp), %eax
	movl	$1, %esi
	movl	%eax, %ecx
	sall	%cl, %esi
	movl	%esi, %eax
	movl	%edx, %ecx
	xorl	%eax, %ecx
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	d(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	addl	$1, -8(%rbp)
.L6:
	movl	C(%rip), %eax
	cmpl	%eax, -8(%rbp)
	jl	.L7
	movl	-20(%rbp), %eax
	addl	$1, %eax
	movl	%eax, %edi
	call	dfs
	cmpl	%eax, -12(%rbp)
	jg	.L8
	movl	-20(%rbp), %eax
	addl	$1, %eax
	movl	%eax, %edi
	call	dfs
	jmp	.L9
.L8:
	movl	-12(%rbp), %eax
.L9:
	movl	%eax, -12(%rbp)
	movl	$0, -8(%rbp)
	jmp	.L10
.L11:
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	d(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-20(%rbp), %eax
	movl	$1, %esi
	movl	%eax, %ecx
	sall	%cl, %esi
	movl	%esi, %eax
	movl	%edx, %ecx
	xorl	%eax, %ecx
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	d(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	addl	$1, -8(%rbp)
.L10:
	movl	C(%rip), %eax
	cmpl	%eax, -8(%rbp)
	jl	.L11
.L5:
	movl	-12(%rbp), %eax
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	dfs, .-dfs
	.section	.rodata
.LC0:
	.string	"%d%d"
.LC1:
	.string	"%d"
.LC2:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB1:
	.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	%rsi, -48(%rbp)
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	$0, -16(%rbp)
	jmp	.L14
.L17:
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	bc(%rip), %rax
	movl	$0, (%rdx,%rax)
	movl	$1, -12(%rbp)
	jmp	.L15
.L16:
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	bc(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-16(%rbp), %eax
	andl	-12(%rbp), %eax
	testl	%eax, %eax
	setne	%al
	movzbl	%al, %eax
	leal	(%rdx,%rax), %ecx
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	bc(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	sall	-12(%rbp)
.L15:
	movl	-12(%rbp), %eax
	cmpl	-16(%rbp), %eax
	jle	.L16
	addl	$1, -16(%rbp)
.L14:
	cmpl	$1023, -16(%rbp)
	jle	.L17
.L24:
	leaq	C(%rip), %rax
	movq	%rax, %rdx
	leaq	R(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	R(%rip), %edx
	movl	C(%rip), %eax
	orl	%edx, %eax
	testl	%eax, %eax
	je	.L28
	movl	$40000, %edx
	movl	$0, %esi
	leaq	d(%rip), %rax
	movq	%rax, %rdi
	call	memset@PLT
	movl	$0, -12(%rbp)
	jmp	.L20
.L23:
	movl	$0, -16(%rbp)
	jmp	.L21
.L22:
	leaq	-20(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	d(%rip), %rax
	movl	(%rdx,%rax), %esi
	movl	-20(%rbp), %edx
	movl	-12(%rbp), %eax
	movl	%eax, %ecx
	sall	%cl, %edx
	movl	%edx, %eax
	movl	%esi, %ecx
	orl	%eax, %ecx
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	d(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	addl	$1, -16(%rbp)
.L21:
	movl	C(%rip), %eax
	cmpl	%eax, -16(%rbp)
	jl	.L22
	addl	$1, -12(%rbp)
.L20:
	movl	R(%rip), %eax
	cmpl	%eax, -12(%rbp)
	jl	.L23
	movl	$0, %edi
	call	dfs
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L24
.L28:
	nop
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L26
	call	__stack_chk_fail@PLT
.L26:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.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
	.local	d
	.comm	d,40000,32
	.local	bc
	.comm	bc,4096,32
	.local	R
	.comm	R,4,4
	.local	C
	.comm	C,4,4
	.type	dfs, @function
dfs:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$32, %rsp
	movl	%edi, -20(%rbp)
	movl	R(%rip), %eax
	cmpl	%eax, -20(%rbp)
	jl	.L2
	movl	$0, -12(%rbp)
	movl	$0, -8(%rbp)
	jmp	.L3
.L4:
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	d(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, %eax
	leaq	0(,%rax,4), %rdx
	leaq	bc(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -4(%rbp)
	movl	R(%rip), %eax
	subl	-4(%rbp), %eax
	movl	%eax, %edx
	movl	-4(%rbp), %eax
	cmpl	%eax, %edx
	cmovge	%edx, %eax
	addl	%eax, -12(%rbp)
	addl	$1, -8(%rbp)
.L3:
	movl	C(%rip), %eax
	cmpl	%eax, -8(%rbp)
	jl	.L4
	jmp	.L5
.L2:
	movl	-20(%rbp), %eax
	addl	$1, %eax
	movl	%eax, %edi
	call	dfs
	movl	%eax, -12(%rbp)
	movl	$0, -8(%rbp)
	jmp	.L6
.L7:
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	d(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-20(%rbp), %eax
	movl	$1, %esi
	movl	%eax, %ecx
	sall	%cl, %esi
	movl	%esi, %eax
	movl	%edx, %ecx
	xorl	%eax, %ecx
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	d(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	addl	$1, -8(%rbp)
.L6:
	movl	C(%rip), %eax
	cmpl	%eax, -8(%rbp)
	jl	.L7
	movl	-20(%rbp), %eax
	addl	$1, %eax
	movl	%eax, %edi
	call	dfs
	cmpl	%eax, -12(%rbp)
	jg	.L8
	movl	-20(%rbp), %eax
	addl	$1, %eax
	movl	%eax, %edi
	call	dfs
	jmp	.L9
.L8:
	movl	-12(%rbp), %eax
.L9:
	movl	%eax, -12(%rbp)
	movl	$0, -8(%rbp)
	jmp	.L10
.L11:
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	d(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-20(%rbp), %eax
	movl	$1, %esi
	movl	%eax, %ecx
	sall	%cl, %esi
	movl	%esi, %eax
	movl	%edx, %ecx
	xorl	%eax, %ecx
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	d(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	addl	$1, -8(%rbp)
.L10:
	movl	C(%rip), %eax
	cmpl	%eax, -8(%rbp)
	jl	.L11
.L5:
	movl	-12(%rbp), %eax
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	dfs, .-dfs
	.section	.rodata
.LC0:
	.string	"%d%d"
.LC1:
	.string	"%d"
.LC2:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB1:
	.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	%rsi, -48(%rbp)
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	$0, -16(%rbp)
	jmp	.L14
.L17:
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	bc(%rip), %rax
	movl	$0, (%rdx,%rax)
	movl	$1, -12(%rbp)
	jmp	.L15
.L16:
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	bc(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-16(%rbp), %eax
	andl	-12(%rbp), %eax
	testl	%eax, %eax
	setne	%al
	movzbl	%al, %eax
	leal	(%rdx,%rax), %ecx
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	bc(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	sall	-12(%rbp)
.L15:
	movl	-12(%rbp), %eax
	cmpl	-16(%rbp), %eax
	jle	.L16
	addl	$1, -16(%rbp)
.L14:
	cmpl	$1023, -16(%rbp)
	jle	.L17
.L24:
	leaq	C(%rip), %rax
	movq	%rax, %rdx
	leaq	R(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	R(%rip), %edx
	movl	C(%rip), %eax
	orl	%edx, %eax
	testl	%eax, %eax
	je	.L28
	movl	$40000, %edx
	movl	$0, %esi
	leaq	d(%rip), %rax
	movq	%rax, %rdi
	call	memset@PLT
	movl	$0, -12(%rbp)
	jmp	.L20
.L23:
	movl	$0, -16(%rbp)
	jmp	.L21
.L22:
	leaq	-20(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	d(%rip), %rax
	movl	(%rdx,%rax), %esi
	movl	-20(%rbp), %edx
	movl	-12(%rbp), %eax
	movl	%eax, %ecx
	sall	%cl, %edx
	movl	%edx, %eax
	movl	%esi, %ecx
	orl	%eax, %ecx
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	d(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	addl	$1, -16(%rbp)
.L21:
	movl	C(%rip), %eax
	cmpl	%eax, -16(%rbp)
	jl	.L22
	addl	$1, -12(%rbp)
.L20:
	movl	R(%rip), %eax
	cmpl	%eax, -12(%rbp)
	jl	.L23
	movl	$0, %edi
	call	dfs
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L24
.L28:
	nop
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L26
	call	__stack_chk_fail@PLT
.L26:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.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:
