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

```c
/*
  AOJ 0151
  Title:Grid
  @kankichi573
*/
#include <stdio.h>
int max(int x,int y) 
{
return  (((x)>(y))?(x):(y));
}
int n;
char grid[255][256];
int max_ren(int sx,int sy,int xoffs,int yoffs,int limit)
{
  int i,j,ren=0,max_=0;

  for(i=sx,j=sy;i<limit && i>=0 && j<limit && j >= 0 ;i+=xoffs,j+=yoffs)
    {
    if(grid[i][j]=='1')
      {
	ren++;
	if(ren>max_)
	  max_=ren;
      }
    else
      ren=0;
    }
  return(max_);
}
int solve()
{
  int i,ret;

  ret=0;
  for(i=0;i<n;i++)
    {
      ret=max(ret,max_ren(0,i,1,0,n));
      ret=max(ret,max_ren(0,i,1,1,n));
      ret=max(ret,max_ren(0,i,1,-1,n));
    }
  for(i=0;i<n;i++)
    {
      ret=max(ret,max_ren(i,0,0,1,n));
      ret=max(ret,max_ren(i,0,1,1,n));
    }
  for(i=0;i<n;i++)
    ret=max(ret,max_ren(i,n-1,1,-1,n));
  return(ret);
}
main()
{
  int  i;

  while(scanf("%d",&n) && n)
    {
      for(i=0;i<n;i++)
	scanf("%s",&grid[i][0]);
      printf("%d\n",solve());
    }
  return(0);
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	max
	.type	max, @function
max:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	%edi, -4(%rbp)
	movl	%esi, -8(%rbp)
	movl	-8(%rbp), %edx
	movl	-4(%rbp), %eax
	cmpl	%eax, %edx
	cmovge	%edx, %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	max, .-max
	.globl	n
	.bss
	.align 4
	.type	n, @object
	.size	n, 4
n:
	.zero	4
	.globl	grid
	.align 32
	.type	grid, @object
	.size	grid, 65280
grid:
	.zero	65280
	.text
	.globl	max_ren
	.type	max_ren, @function
max_ren:
.LFB1:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	%edi, -20(%rbp)
	movl	%esi, -24(%rbp)
	movl	%edx, -28(%rbp)
	movl	%ecx, -32(%rbp)
	movl	%r8d, -36(%rbp)
	movl	$0, -8(%rbp)
	movl	$0, -4(%rbp)
	movl	-20(%rbp), %eax
	movl	%eax, -16(%rbp)
	movl	-24(%rbp), %eax
	movl	%eax, -12(%rbp)
	jmp	.L4
.L8:
	movl	-12(%rbp), %eax
	movslq	%eax, %rdx
	movl	-16(%rbp), %eax
	cltq
	salq	$8, %rax
	addq	%rax, %rdx
	leaq	grid(%rip), %rax
	addq	%rdx, %rax
	movzbl	(%rax), %eax
	cmpb	$49, %al
	jne	.L5
	addl	$1, -8(%rbp)
	movl	-8(%rbp), %eax
	cmpl	-4(%rbp), %eax
	jle	.L6
	movl	-8(%rbp), %eax
	movl	%eax, -4(%rbp)
	jmp	.L6
.L5:
	movl	$0, -8(%rbp)
.L6:
	movl	-28(%rbp), %eax
	addl	%eax, -16(%rbp)
	movl	-32(%rbp), %eax
	addl	%eax, -12(%rbp)
.L4:
	movl	-16(%rbp), %eax
	cmpl	-36(%rbp), %eax
	jge	.L7
	cmpl	$0, -16(%rbp)
	js	.L7
	movl	-12(%rbp), %eax
	cmpl	-36(%rbp), %eax
	jge	.L7
	cmpl	$0, -12(%rbp)
	jns	.L8
.L7:
	movl	-4(%rbp), %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.size	max_ren, .-max_ren
	.globl	solve
	.type	solve, @function
solve:
.LFB2:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$16, %rsp
	movl	$0, -4(%rbp)
	movl	$0, -8(%rbp)
	jmp	.L11
.L12:
	movl	n(%rip), %edx
	movl	-8(%rbp), %eax
	movl	%edx, %r8d
	movl	$0, %ecx
	movl	$1, %edx
	movl	%eax, %esi
	movl	$0, %edi
	call	max_ren
	movl	%eax, %edx
	movl	-4(%rbp), %eax
	movl	%edx, %esi
	movl	%eax, %edi
	call	max
	movl	%eax, -4(%rbp)
	movl	n(%rip), %edx
	movl	-8(%rbp), %eax
	movl	%edx, %r8d
	movl	$1, %ecx
	movl	$1, %edx
	movl	%eax, %esi
	movl	$0, %edi
	call	max_ren
	movl	%eax, %edx
	movl	-4(%rbp), %eax
	movl	%edx, %esi
	movl	%eax, %edi
	call	max
	movl	%eax, -4(%rbp)
	movl	n(%rip), %edx
	movl	-8(%rbp), %eax
	movl	%edx, %r8d
	movl	$-1, %ecx
	movl	$1, %edx
	movl	%eax, %esi
	movl	$0, %edi
	call	max_ren
	movl	%eax, %edx
	movl	-4(%rbp), %eax
	movl	%edx, %esi
	movl	%eax, %edi
	call	max
	movl	%eax, -4(%rbp)
	addl	$1, -8(%rbp)
.L11:
	movl	n(%rip), %eax
	cmpl	%eax, -8(%rbp)
	jl	.L12
	movl	$0, -8(%rbp)
	jmp	.L13
.L14:
	movl	n(%rip), %edx
	movl	-8(%rbp), %eax
	movl	%edx, %r8d
	movl	$1, %ecx
	movl	$0, %edx
	movl	$0, %esi
	movl	%eax, %edi
	call	max_ren
	movl	%eax, %edx
	movl	-4(%rbp), %eax
	movl	%edx, %esi
	movl	%eax, %edi
	call	max
	movl	%eax, -4(%rbp)
	movl	n(%rip), %edx
	movl	-8(%rbp), %eax
	movl	%edx, %r8d
	movl	$1, %ecx
	movl	$1, %edx
	movl	$0, %esi
	movl	%eax, %edi
	call	max_ren
	movl	%eax, %edx
	movl	-4(%rbp), %eax
	movl	%edx, %esi
	movl	%eax, %edi
	call	max
	movl	%eax, -4(%rbp)
	addl	$1, -8(%rbp)
.L13:
	movl	n(%rip), %eax
	cmpl	%eax, -8(%rbp)
	jl	.L14
	movl	$0, -8(%rbp)
	jmp	.L15
.L16:
	movl	n(%rip), %edx
	movl	n(%rip), %eax
	leal	-1(%rax), %esi
	movl	-8(%rbp), %eax
	movl	%edx, %r8d
	movl	$-1, %ecx
	movl	$1, %edx
	movl	%eax, %edi
	call	max_ren
	movl	%eax, %edx
	movl	-4(%rbp), %eax
	movl	%edx, %esi
	movl	%eax, %edi
	call	max
	movl	%eax, -4(%rbp)
	addl	$1, -8(%rbp)
.L15:
	movl	n(%rip), %eax
	cmpl	%eax, -8(%rbp)
	jl	.L16
	movl	-4(%rbp), %eax
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE2:
	.size	solve, .-solve
	.section	.rodata
.LC0:
	.string	"%s"
.LC1:
	.string	"%d\n"
.LC2:
	.string	"%d"
	.text
	.globl	main
	.type	main, @function
main:
.LFB3:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$16, %rsp
	jmp	.L19
.L23:
	movl	$0, -4(%rbp)
	jmp	.L20
.L21:
	movl	-4(%rbp), %eax
	cltq
	salq	$8, %rax
	movq	%rax, %rdx
	leaq	grid(%rip), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -4(%rbp)
.L20:
	movl	n(%rip), %eax
	cmpl	%eax, -4(%rbp)
	jl	.L21
	movl	$0, %eax
	call	solve
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L19:
	leaq	n(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	testl	%eax, %eax
	je	.L22
	movl	n(%rip), %eax
	testl	%eax, %eax
	jne	.L23
.L22:
	movl	$0, %eax
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE3:
	.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	max
	.type	max, @function
max:
.LFB23:
	.cfi_startproc
	endbr64
	cmpl	%edi, %esi
	movl	%edi, %eax
	cmovge	%esi, %eax
	ret
	.cfi_endproc
.LFE23:
	.size	max, .-max
	.p2align 4
	.globl	max_ren
	.type	max_ren, @function
max_ren:
.LFB24:
	.cfi_startproc
	endbr64
	movl	%edi, %eax
	movl	%edx, %edi
	movl	%eax, %edx
	orl	%esi, %edx
	js	.L17
	cmpl	%r8d, %eax
	jge	.L17
	cmpl	%r8d, %esi
	jge	.L17
	cmpl	$1, %ecx
	jne	.L37
	movslq	%eax, %rdx
	movslq	%esi, %rcx
	movslq	%edi, %r10
	xorl	%r9d, %r9d
	salq	$8, %rdx
	salq	$8, %r10
	addq	%rcx, %rdx
	leaq	grid(%rip), %rcx
	addq	$1, %r10
	addq	%rcx, %rdx
	xorl	%ecx, %ecx
	jmp	.L13
	.p2align 4,,10
	.p2align 3
.L19:
	addl	%edi, %eax
	xorl	%ecx, %ecx
	addl	$1, %esi
	cmpl	%eax, %r8d
	jle	.L3
.L38:
	testl	%eax, %eax
	js	.L3
	addq	%r10, %rdx
	cmpl	%esi, %r8d
	jle	.L3
	testl	%esi, %esi
	js	.L3
.L13:
	cmpb	$49, (%rdx)
	jne	.L19
	addl	$1, %ecx
	cmpl	%ecx, %r9d
	cmovl	%ecx, %r9d
	addl	%edi, %eax
	addl	$1, %esi
	cmpl	%eax, %r8d
	jg	.L38
.L3:
	movl	%r9d, %eax
	ret
	.p2align 4,,10
	.p2align 3
.L37:
	movslq	%edi, %r11
	movslq	%ecx, %rdx
	movslq	%esi, %r9
	xorl	%r10d, %r10d
	salq	$8, %r11
	addq	%rdx, %r11
	movslq	%eax, %rdx
	salq	$8, %rdx
	addq	%r9, %rdx
	leaq	grid(%rip), %r9
	addq	%r9, %rdx
	xorl	%r9d, %r9d
	jmp	.L9
	.p2align 4,,10
	.p2align 3
.L18:
	xorl	%r10d, %r10d
.L6:
	addl	%edi, %eax
	addl	%ecx, %esi
	cmpl	%eax, %r8d
	jle	.L3
	testl	%eax, %eax
	js	.L3
	addq	%r11, %rdx
	cmpl	%esi, %r8d
	jle	.L3
	testl	%esi, %esi
	js	.L3
.L9:
	cmpb	$49, (%rdx)
	jne	.L18
	addl	$1, %r10d
	cmpl	%r10d, %r9d
	cmovl	%r10d, %r9d
	jmp	.L6
	.p2align 4,,10
	.p2align 3
.L17:
	xorl	%r9d, %r9d
	movl	%r9d, %eax
	ret
	.cfi_endproc
.LFE24:
	.size	max_ren, .-max_ren
	.p2align 4
	.globl	solve
	.type	solve, @function
solve:
.LFB25:
	.cfi_startproc
	endbr64
	movl	n(%rip), %edx
	testl	%edx, %edx
	jle	.L64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	leal	-1(%rdx), %eax
	movl	%edx, %r11d
	xorl	%r8d, %r8d
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	movq	%rax, %r9
	leaq	grid(%rip), %r14
	movq	%rax, %r15
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	salq	$8, %r9
	negl	%r11d
	movq	%r14, %r13
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	movl	%edx, %r12d
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	movl	%edx, %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	movq	%rax, -8(%rsp)
	leaq	256(%r14), %rax
	addq	%rax, %r9
	.p2align 4,,10
	.p2align 3
.L52:
	leal	(%rdx,%r11), %ecx
	movq	%r13, %rax
	xorl	%edi, %edi
	xorl	%esi, %esi
	jmp	.L42
	.p2align 4,,10
	.p2align 3
.L65:
	addq	$256, %rax
	xorl	%esi, %esi
	cmpq	%r9, %rax
	je	.L88
.L42:
	cmpb	$49, (%rax)
	jne	.L65
	addl	$1, %esi
	cmpl	%esi, %edi
	cmovl	%esi, %edi
	addq	$256, %rax
	cmpq	%r9, %rax
	jne	.L42
.L88:
	movq	%r13, %rsi
	movl	%ecx, %eax
	xorl	%ebx, %ebx
	xorl	%r10d, %r10d
	jmp	.L43
	.p2align 4,,10
	.p2align 3
.L66:
	addl	$1, %eax
	xorl	%r10d, %r10d
	addq	$257, %rsi
	cmpl	%r12d, %eax
	je	.L45
.L43:
	cmpl	%eax, %edx
	jle	.L45
	cmpb	$49, (%rsi)
	jne	.L66
	addl	$1, %r10d
	cmpl	%r10d, %ebx
	cmovl	%r10d, %ebx
	addl	$1, %eax
	addq	$257, %rsi
	cmpl	%r12d, %eax
	jne	.L43
	.p2align 4,,10
	.p2align 3
.L45:
	cmpl	%ebx, %edi
	movq	%r13, %rax
	cmovl	%ebx, %edi
	cmpl	%r8d, %edi
	cmovl	%r8d, %edi
	xorl	%r8d, %r8d
	xorl	%esi, %esi
	jmp	.L47
	.p2align 4,,10
	.p2align 3
.L67:
	subl	$1, %ecx
	xorl	%esi, %esi
	addq	$255, %rax
	cmpl	%r11d, %ecx
	je	.L49
.L47:
	cmpl	%ecx, %edx
	jle	.L49
	testl	%ecx, %ecx
	js	.L49
	cmpb	$49, (%rax)
	jne	.L67
	addl	$1, %esi
	cmpl	%esi, %r8d
	cmovl	%esi, %r8d
	subl	$1, %ecx
	addq	$255, %rax
	cmpl	%r11d, %ecx
	jne	.L47
	.p2align 4,,10
	.p2align 3
.L49:
	cmpl	%r8d, %edi
	cmovge	%edi, %r8d
	addq	$1, %r13
	addq	$1, %r9
	addl	$1, %r12d
	addl	$1, %r11d
	jne	.L52
	leaq	1+grid(%rip), %rdi
	movl	%edx, %r9d
	xorl	%r10d, %r10d
	addq	-8(%rsp), %rdi
	.p2align 4,,10
	.p2align 3
.L58:
	movq	%r14, %rax
	xorl	%esi, %esi
	xorl	%ecx, %ecx
	jmp	.L54
	.p2align 4,,10
	.p2align 3
.L68:
	addq	$1, %rax
	xorl	%ecx, %ecx
	cmpq	%rdi, %rax
	je	.L89
.L54:
	cmpb	$49, (%rax)
	jne	.L68
	addl	$1, %ecx
	cmpl	%ecx, %esi
	cmovl	%ecx, %esi
	addq	$1, %rax
	cmpq	%rdi, %rax
	jne	.L54
.L89:
	movq	%r14, %rcx
	movl	%r10d, %eax
	xorl	%ebx, %ebx
	xorl	%r11d, %r11d
	jmp	.L57
	.p2align 4,,10
	.p2align 3
.L69:
	addl	$1, %eax
	xorl	%r11d, %r11d
	cmpl	%edx, %eax
	jge	.L56
.L90:
	addq	$257, %rcx
	cmpl	%r9d, %eax
	je	.L56
.L57:
	cmpb	$49, (%rcx)
	jne	.L69
	addl	$1, %r11d
	cmpl	%r11d, %ebx
	cmovl	%r11d, %ebx
	addl	$1, %eax
	cmpl	%edx, %eax
	jl	.L90
	.p2align 4,,10
	.p2align 3
.L56:
	cmpl	%ebx, %esi
	cmovl	%ebx, %esi
	cmpl	%esi, %r8d
	cmovl	%esi, %r8d
	addl	$1, %r10d
	addl	$1, %r9d
	addq	$256, %r14
	addq	$256, %rdi
	cmpl	%edx, %r10d
	jne	.L58
	movslq	%edx, %rax
	leaq	grid(%rip), %rbx
	xorl	%r11d, %r11d
	leaq	(%rbx,%rax), %r10
	.p2align 4,,10
	.p2align 3
.L63:
	movq	%r10, %rsi
	movl	%r15d, %eax
	xorl	%r9d, %r9d
	xorl	%edi, %edi
	jmp	.L61
	.p2align 4,,10
	.p2align 3
.L70:
	subl	$1, %eax
	movl	%ebp, %ecx
	xorl	%edi, %edi
	subl	%eax, %ecx
	subl	$1, %ecx
	cmpl	%edx, %ecx
	jge	.L60
.L91:
	addq	$255, %rsi
	cmpl	%edx, %eax
	jge	.L60
	testl	%eax, %eax
	js	.L60
.L61:
	cmpb	$49, -1(%rsi)
	jne	.L70
	addl	$1, %edi
	movl	%ebp, %ecx
	cmpl	%edi, %r9d
	cmovl	%edi, %r9d
	subl	$1, %eax
	subl	%eax, %ecx
	subl	$1, %ecx
	cmpl	%edx, %ecx
	jl	.L91
	.p2align 4,,10
	.p2align 3
.L60:
	cmpl	%r9d, %r8d
	cmovl	%r9d, %r8d
	addl	$1, %r11d
	addl	$1, %ebp
	addq	$256, %r10
	cmpl	%edx, %r11d
	jne	.L63
	popq	%rbx
	.cfi_def_cfa_offset 48
	movl	%r8d, %eax
	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
.L64:
	.cfi_restore 3
	.cfi_restore 6
	.cfi_restore 12
	.cfi_restore 13
	.cfi_restore 14
	.cfi_restore 15
	xorl	%eax, %eax
	ret
	.cfi_endproc
.LFE25:
	.size	solve, .-solve
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%s"
.LC1:
	.string	"%d\n"
.LC2:
	.string	"%d"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB26:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	leaq	.LC1(%rip), %r15
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	leaq	n(%rip), %r14
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	leaq	.LC2(%rip), %r13
	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	$8, %rsp
	.cfi_def_cfa_offset 64
	.p2align 4,,10
	.p2align 3
.L93:
	xorl	%eax, %eax
	movq	%r14, %rsi
	movq	%r13, %rdi
	call	__isoc99_scanf@PLT
	testl	%eax, %eax
	je	.L95
	movl	n(%rip), %eax
	testl	%eax, %eax
	je	.L95
	leaq	grid(%rip), %rbp
	movl	$0, %ebx
	jle	.L97
	.p2align 4,,10
	.p2align 3
.L94:
	movq	%rbp, %rsi
	xorl	%eax, %eax
	movq	%r12, %rdi
	addl	$1, %ebx
	call	__isoc99_scanf@PLT
	addq	$256, %rbp
	cmpl	%ebx, n(%rip)
	jg	.L94
.L97:
	xorl	%eax, %eax
	call	solve
	movq	%r15, %rsi
	movl	$1, %edi
	movl	%eax, %edx
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L93
	.p2align 4,,10
	.p2align 3
.L95:
	addq	$8, %rsp
	.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
	.cfi_endproc
.LFE26:
	.size	main, .-main
	.globl	grid
	.bss
	.align 32
	.type	grid, @object
	.size	grid, 65280
grid:
	.zero	65280
	.globl	n
	.align 4
	.type	n, @object
	.size	n, 4
n:
	.zero	4
	.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	max
	.type	max, @function
max:
.LFB23:
	.cfi_startproc
	endbr64
	cmpl	%edi, %esi
	movl	%edi, %eax
	cmovge	%esi, %eax
	ret
	.cfi_endproc
.LFE23:
	.size	max, .-max
	.p2align 4
	.globl	max_ren
	.type	max_ren, @function
max_ren:
.LFB24:
	.cfi_startproc
	endbr64
	movl	%edi, %eax
	movl	%edx, %edi
	movl	%eax, %edx
	orl	%esi, %edx
	js	.L17
	cmpl	%r8d, %eax
	jge	.L17
	cmpl	%r8d, %esi
	jge	.L17
	cmpl	$1, %ecx
	jne	.L37
	movslq	%eax, %rdx
	movslq	%esi, %rcx
	movslq	%edi, %r10
	xorl	%r9d, %r9d
	salq	$8, %rdx
	salq	$8, %r10
	addq	%rcx, %rdx
	leaq	grid(%rip), %rcx
	addq	$1, %r10
	addq	%rcx, %rdx
	xorl	%ecx, %ecx
	jmp	.L13
	.p2align 4,,10
	.p2align 3
.L19:
	addl	%edi, %eax
	xorl	%ecx, %ecx
	addl	$1, %esi
	cmpl	%eax, %r8d
	jle	.L3
.L38:
	testl	%eax, %eax
	js	.L3
	addq	%r10, %rdx
	cmpl	%esi, %r8d
	jle	.L3
	testl	%esi, %esi
	js	.L3
.L13:
	cmpb	$49, (%rdx)
	jne	.L19
	addl	$1, %ecx
	cmpl	%ecx, %r9d
	cmovl	%ecx, %r9d
	addl	%edi, %eax
	addl	$1, %esi
	cmpl	%eax, %r8d
	jg	.L38
.L3:
	movl	%r9d, %eax
	ret
	.p2align 4,,10
	.p2align 3
.L37:
	movslq	%edi, %r11
	movslq	%ecx, %rdx
	movslq	%esi, %r9
	xorl	%r10d, %r10d
	salq	$8, %r11
	addq	%rdx, %r11
	movslq	%eax, %rdx
	salq	$8, %rdx
	addq	%r9, %rdx
	leaq	grid(%rip), %r9
	addq	%r9, %rdx
	xorl	%r9d, %r9d
	jmp	.L9
	.p2align 4,,10
	.p2align 3
.L18:
	xorl	%r10d, %r10d
.L6:
	addl	%edi, %eax
	addl	%ecx, %esi
	cmpl	%eax, %r8d
	jle	.L3
	testl	%eax, %eax
	js	.L3
	addq	%r11, %rdx
	cmpl	%esi, %r8d
	jle	.L3
	testl	%esi, %esi
	js	.L3
.L9:
	cmpb	$49, (%rdx)
	jne	.L18
	addl	$1, %r10d
	cmpl	%r10d, %r9d
	cmovl	%r10d, %r9d
	jmp	.L6
	.p2align 4,,10
	.p2align 3
.L17:
	xorl	%r9d, %r9d
	movl	%r9d, %eax
	ret
	.cfi_endproc
.LFE24:
	.size	max_ren, .-max_ren
	.p2align 4
	.globl	solve
	.type	solve, @function
solve:
.LFB25:
	.cfi_startproc
	endbr64
	movl	n(%rip), %edx
	testl	%edx, %edx
	jle	.L64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	leal	-1(%rdx), %eax
	movl	%edx, %r11d
	xorl	%r8d, %r8d
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	movq	%rax, %r9
	leaq	grid(%rip), %r14
	movq	%rax, %r15
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	salq	$8, %r9
	negl	%r11d
	movq	%r14, %r13
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	movl	%edx, %r12d
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	movl	%edx, %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	movq	%rax, -8(%rsp)
	leaq	256(%r14), %rax
	addq	%rax, %r9
	.p2align 4,,10
	.p2align 3
.L52:
	leal	(%rdx,%r11), %ecx
	movq	%r13, %rax
	xorl	%edi, %edi
	xorl	%esi, %esi
	jmp	.L42
	.p2align 4,,10
	.p2align 3
.L65:
	addq	$256, %rax
	xorl	%esi, %esi
	cmpq	%r9, %rax
	je	.L88
.L42:
	cmpb	$49, (%rax)
	jne	.L65
	addl	$1, %esi
	cmpl	%esi, %edi
	cmovl	%esi, %edi
	addq	$256, %rax
	cmpq	%r9, %rax
	jne	.L42
.L88:
	movq	%r13, %rsi
	movl	%ecx, %eax
	xorl	%ebx, %ebx
	xorl	%r10d, %r10d
	jmp	.L43
	.p2align 4,,10
	.p2align 3
.L66:
	addl	$1, %eax
	xorl	%r10d, %r10d
	addq	$257, %rsi
	cmpl	%r12d, %eax
	je	.L45
.L43:
	cmpl	%eax, %edx
	jle	.L45
	cmpb	$49, (%rsi)
	jne	.L66
	addl	$1, %r10d
	cmpl	%r10d, %ebx
	cmovl	%r10d, %ebx
	addl	$1, %eax
	addq	$257, %rsi
	cmpl	%r12d, %eax
	jne	.L43
	.p2align 4,,10
	.p2align 3
.L45:
	cmpl	%ebx, %edi
	movq	%r13, %rax
	cmovl	%ebx, %edi
	cmpl	%r8d, %edi
	cmovl	%r8d, %edi
	xorl	%r8d, %r8d
	xorl	%esi, %esi
	jmp	.L47
	.p2align 4,,10
	.p2align 3
.L67:
	subl	$1, %ecx
	xorl	%esi, %esi
	addq	$255, %rax
	cmpl	%r11d, %ecx
	je	.L49
.L47:
	cmpl	%ecx, %edx
	jle	.L49
	testl	%ecx, %ecx
	js	.L49
	cmpb	$49, (%rax)
	jne	.L67
	addl	$1, %esi
	cmpl	%esi, %r8d
	cmovl	%esi, %r8d
	subl	$1, %ecx
	addq	$255, %rax
	cmpl	%r11d, %ecx
	jne	.L47
	.p2align 4,,10
	.p2align 3
.L49:
	cmpl	%r8d, %edi
	cmovge	%edi, %r8d
	addq	$1, %r13
	addq	$1, %r9
	addl	$1, %r12d
	addl	$1, %r11d
	jne	.L52
	leaq	1+grid(%rip), %rdi
	movl	%edx, %r9d
	xorl	%r10d, %r10d
	addq	-8(%rsp), %rdi
	.p2align 4,,10
	.p2align 3
.L58:
	movq	%r14, %rax
	xorl	%esi, %esi
	xorl	%ecx, %ecx
	jmp	.L54
	.p2align 4,,10
	.p2align 3
.L68:
	addq	$1, %rax
	xorl	%ecx, %ecx
	cmpq	%rdi, %rax
	je	.L89
.L54:
	cmpb	$49, (%rax)
	jne	.L68
	addl	$1, %ecx
	cmpl	%ecx, %esi
	cmovl	%ecx, %esi
	addq	$1, %rax
	cmpq	%rdi, %rax
	jne	.L54
.L89:
	movq	%r14, %rcx
	movl	%r10d, %eax
	xorl	%ebx, %ebx
	xorl	%r11d, %r11d
	jmp	.L57
	.p2align 4,,10
	.p2align 3
.L69:
	addl	$1, %eax
	xorl	%r11d, %r11d
	cmpl	%edx, %eax
	jge	.L56
.L90:
	addq	$257, %rcx
	cmpl	%r9d, %eax
	je	.L56
.L57:
	cmpb	$49, (%rcx)
	jne	.L69
	addl	$1, %r11d
	cmpl	%r11d, %ebx
	cmovl	%r11d, %ebx
	addl	$1, %eax
	cmpl	%edx, %eax
	jl	.L90
	.p2align 4,,10
	.p2align 3
.L56:
	cmpl	%ebx, %esi
	cmovl	%ebx, %esi
	cmpl	%esi, %r8d
	cmovl	%esi, %r8d
	addl	$1, %r10d
	addl	$1, %r9d
	addq	$256, %r14
	addq	$256, %rdi
	cmpl	%edx, %r10d
	jne	.L58
	movslq	%edx, %rax
	leaq	grid(%rip), %rbx
	xorl	%r11d, %r11d
	leaq	(%rbx,%rax), %r10
	.p2align 4,,10
	.p2align 3
.L63:
	movq	%r10, %rsi
	movl	%r15d, %eax
	xorl	%r9d, %r9d
	xorl	%edi, %edi
	jmp	.L61
	.p2align 4,,10
	.p2align 3
.L70:
	subl	$1, %eax
	movl	%ebp, %ecx
	xorl	%edi, %edi
	subl	%eax, %ecx
	subl	$1, %ecx
	cmpl	%edx, %ecx
	jge	.L60
.L91:
	addq	$255, %rsi
	cmpl	%edx, %eax
	jge	.L60
	testl	%eax, %eax
	js	.L60
.L61:
	cmpb	$49, -1(%rsi)
	jne	.L70
	addl	$1, %edi
	movl	%ebp, %ecx
	cmpl	%edi, %r9d
	cmovl	%edi, %r9d
	subl	$1, %eax
	subl	%eax, %ecx
	subl	$1, %ecx
	cmpl	%edx, %ecx
	jl	.L91
	.p2align 4,,10
	.p2align 3
.L60:
	cmpl	%r9d, %r8d
	cmovl	%r9d, %r8d
	addl	$1, %r11d
	addl	$1, %ebp
	addq	$256, %r10
	cmpl	%edx, %r11d
	jne	.L63
	popq	%rbx
	.cfi_def_cfa_offset 48
	movl	%r8d, %eax
	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
.L64:
	.cfi_restore 3
	.cfi_restore 6
	.cfi_restore 12
	.cfi_restore 13
	.cfi_restore 14
	.cfi_restore 15
	xorl	%eax, %eax
	ret
	.cfi_endproc
.LFE25:
	.size	solve, .-solve
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%s"
.LC1:
	.string	"%d\n"
.LC2:
	.string	"%d"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB26:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	leaq	.LC1(%rip), %r15
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	leaq	n(%rip), %r14
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	leaq	.LC2(%rip), %r13
	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	$8, %rsp
	.cfi_def_cfa_offset 64
	.p2align 4,,10
	.p2align 3
.L93:
	xorl	%eax, %eax
	movq	%r14, %rsi
	movq	%r13, %rdi
	call	__isoc99_scanf@PLT
	testl	%eax, %eax
	je	.L95
	movl	n(%rip), %eax
	testl	%eax, %eax
	je	.L95
	leaq	grid(%rip), %rbp
	movl	$0, %ebx
	jle	.L97
	.p2align 4,,10
	.p2align 3
.L94:
	movq	%rbp, %rsi
	xorl	%eax, %eax
	movq	%r12, %rdi
	addl	$1, %ebx
	call	__isoc99_scanf@PLT
	addq	$256, %rbp
	cmpl	%ebx, n(%rip)
	jg	.L94
.L97:
	xorl	%eax, %eax
	call	solve
	movq	%r15, %rsi
	movl	$1, %edi
	movl	%eax, %edx
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L93
	.p2align 4,,10
	.p2align 3
.L95:
	addq	$8, %rsp
	.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
	.cfi_endproc
.LFE26:
	.size	main, .-main
	.globl	grid
	.bss
	.align 32
	.type	grid, @object
	.size	grid, 65280
grid:
	.zero	65280
	.globl	n
	.align 4
	.type	n, @object
	.size	n, 4
n:
	.zero	4
	.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:

/*
  AOJ 0151
  Title:Grid
  @kankichi573
*/
#include <stdio.h>
int max(int x,int y) 
{
return  (((x)>(y))?(x):(y));
}
int n;
char grid[255][256];
int max_ren(int sx,int sy,int xoffs,int yoffs,int limit)
{
  int i,j,ren=0,max_=0;

  for(i=sx,j=sy;i<limit && i>=0 && j<limit && j >= 0 ;i+=xoffs,j+=yoffs)
    {
    if(grid[i][j]=='1')
      {
	ren++;
	if(ren>max_)
	  max_=ren;
      }
    else
      ren=0;
    }
  return(max_);
}
int solve()
{
  int i,ret;

  ret=0;
  for(i=0;i<n;i++)
    {
      ret=max(ret,max_ren(0,i,1,0,n));
      ret=max(ret,max_ren(0,i,1,1,n));
      ret=max(ret,max_ren(0,i,1,-1,n));
    }
  for(i=0;i<n;i++)
    {
      ret=max(ret,max_ren(i,0,0,1,n));
      ret=max(ret,max_ren(i,0,1,1,n));
    }
  for(i=0;i<n;i++)
    ret=max(ret,max_ren(i,n-1,1,-1,n));
  return(ret);
}
main()
{
  int  i;

  while(scanf("%d",&n) && n)
    {
      for(i=0;i<n;i++)
	scanf("%s",&grid[i][0]);
      printf("%d\n",solve());
    }
  return(0);
}
5
00011
00101
01000
10101
00010
8
11000001
10110111
01100111
01111010
11111111
01001010
10100010
10000001
2
01
00
3
000
000
000
0
 5
01011
00101
01000
10101
00010
8
11000001
10110111
01100111
01111010
11111111
01001010
10100000
10000001
0
01
00
3
000
000
000
0
 5
01011
00101
01100
10101
00010
8
11000001
10110111
01100111
10111010
10111111
01001010
10100000
10000000
0
01
00
3
001
100
000
0
 5
01011
00000
01000
10101
01010
8
11010001
10110111
01100011
01111010
11111111
01101000
10100010
10000101
0
0
1
6
000
100
000
0
 5
01011
10000
01000
10001
01010
8
11010001
10110111
01100011
01111010
11111111
01101000
10100010
10000101
0
0
1
6
000
100
000
0
 5
00011
00101
01000
10101
00010
8
11000001
10110111
01100111
01111010
11111111
01001010
10100010
10000001
2
01
00
3
000
010
000
0
 5
01011
00100
01000
10101
01010
8
11010001
10110111
01100111
01111010
11011111
01001010
10100000
10000001
0
0
1
3
000
000
000
0
 5
01011
00101
01000
10101
00010
8
11000001
10110111
01100111
01111010
11111111
01001010
10100010
10000001
2
01
00
3
000
011
000
0
 5
01011
00101
01000
10101
00010
8
11100001
10110111
01100111
01111010
11111111
01000010
10100000
10000001
2
01
00
0
000
000
000
0
 5
01010
00101
01000
10101
00010
8
10000001
10110111
01100011
01111010
11111110
01001010
10110000
10000001
0
0
00
1
000
010
100
0

4
8
1
0
 4
8
 4
6
 3
8
 2
8
 4
8
1
1
 4
5
 4
8
1
2
 4
8
1
 4
7

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

```c
/*
  AOJ 0151
  Title:Grid
  @kankichi573
*/
#include <stdio.h>
int max(int x,int y) 
{
return  (((x)>(y))?(x):(y));
}
int n;
char grid[255][256];
int max_ren(int sx,int sy,int xoffs,int yoffs,int limit)
{
  int i,j,ren=0,max_=0;

  for(i=sx,j=sy;i<limit && i>=0 && j<limit && j >= 0 ;i+=xoffs,j+=yoffs)
    {
    if(grid[i][j]=='1')
      {
	ren++;
	if(ren>max_)
	  max_=ren;
      }
    else
      ren=0;
    }
  return(max_);
}
int solve()
{
  int i,ret;

  ret=0;
  for(i=0;i<n;i++)
    {
      ret=max(ret,max_ren(0,i,1,0,n));
      ret=max(ret,max_ren(0,i,1,1,n));
      ret=max(ret,max_ren(0,i,1,-1,n));
    }
  for(i=0;i<n;i++)
    {
      ret=max(ret,max_ren(i,0,0,1,n));
      ret=max(ret,max_ren(i,0,1,1,n));
    }
  for(i=0;i<n;i++)
    ret=max(ret,max_ren(i,n-1,1,-1,n));
  return(ret);
}
main()
{
  int  i;

  while(scanf("%d",&n) && n)
    {
      for(i=0;i<n;i++)
	scanf("%s",&grid[i][0]);
      printf("%d\n",solve());
    }
  return(0);
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	max
	.type	max, @function
max:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	%edi, -4(%rbp)
	movl	%esi, -8(%rbp)
	movl	-8(%rbp), %edx
	movl	-4(%rbp), %eax
	cmpl	%eax, %edx
	cmovge	%edx, %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	max, .-max
	.globl	n
	.bss
	.align 4
	.type	n, @object
	.size	n, 4
n:
	.zero	4
	.globl	grid
	.align 32
	.type	grid, @object
	.size	grid, 65280
grid:
	.zero	65280
	.text
	.globl	max_ren
	.type	max_ren, @function
max_ren:
.LFB1:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	%edi, -20(%rbp)
	movl	%esi, -24(%rbp)
	movl	%edx, -28(%rbp)
	movl	%ecx, -32(%rbp)
	movl	%r8d, -36(%rbp)
	movl	$0, -8(%rbp)
	movl	$0, -4(%rbp)
	movl	-20(%rbp), %eax
	movl	%eax, -16(%rbp)
	movl	-24(%rbp), %eax
	movl	%eax, -12(%rbp)
	jmp	.L4
.L8:
	movl	-12(%rbp), %eax
	movslq	%eax, %rdx
	movl	-16(%rbp), %eax
	cltq
	salq	$8, %rax
	addq	%rax, %rdx
	leaq	grid(%rip), %rax
	addq	%rdx, %rax
	movzbl	(%rax), %eax
	cmpb	$49, %al
	jne	.L5
	addl	$1, -8(%rbp)
	movl	-8(%rbp), %eax
	cmpl	-4(%rbp), %eax
	jle	.L6
	movl	-8(%rbp), %eax
	movl	%eax, -4(%rbp)
	jmp	.L6
.L5:
	movl	$0, -8(%rbp)
.L6:
	movl	-28(%rbp), %eax
	addl	%eax, -16(%rbp)
	movl	-32(%rbp), %eax
	addl	%eax, -12(%rbp)
.L4:
	movl	-16(%rbp), %eax
	cmpl	-36(%rbp), %eax
	jge	.L7
	cmpl	$0, -16(%rbp)
	js	.L7
	movl	-12(%rbp), %eax
	cmpl	-36(%rbp), %eax
	jge	.L7
	cmpl	$0, -12(%rbp)
	jns	.L8
.L7:
	movl	-4(%rbp), %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.size	max_ren, .-max_ren
	.globl	solve
	.type	solve, @function
solve:
.LFB2:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$16, %rsp
	movl	$0, -4(%rbp)
	movl	$0, -8(%rbp)
	jmp	.L11
.L12:
	movl	n(%rip), %edx
	movl	-8(%rbp), %eax
	movl	%edx, %r8d
	movl	$0, %ecx
	movl	$1, %edx
	movl	%eax, %esi
	movl	$0, %edi
	call	max_ren
	movl	%eax, %edx
	movl	-4(%rbp), %eax
	movl	%edx, %esi
	movl	%eax, %edi
	call	max
	movl	%eax, -4(%rbp)
	movl	n(%rip), %edx
	movl	-8(%rbp), %eax
	movl	%edx, %r8d
	movl	$1, %ecx
	movl	$1, %edx
	movl	%eax, %esi
	movl	$0, %edi
	call	max_ren
	movl	%eax, %edx
	movl	-4(%rbp), %eax
	movl	%edx, %esi
	movl	%eax, %edi
	call	max
	movl	%eax, -4(%rbp)
	movl	n(%rip), %edx
	movl	-8(%rbp), %eax
	movl	%edx, %r8d
	movl	$-1, %ecx
	movl	$1, %edx
	movl	%eax, %esi
	movl	$0, %edi
	call	max_ren
	movl	%eax, %edx
	movl	-4(%rbp), %eax
	movl	%edx, %esi
	movl	%eax, %edi
	call	max
	movl	%eax, -4(%rbp)
	addl	$1, -8(%rbp)
.L11:
	movl	n(%rip), %eax
	cmpl	%eax, -8(%rbp)
	jl	.L12
	movl	$0, -8(%rbp)
	jmp	.L13
.L14:
	movl	n(%rip), %edx
	movl	-8(%rbp), %eax
	movl	%edx, %r8d
	movl	$1, %ecx
	movl	$0, %edx
	movl	$0, %esi
	movl	%eax, %edi
	call	max_ren
	movl	%eax, %edx
	movl	-4(%rbp), %eax
	movl	%edx, %esi
	movl	%eax, %edi
	call	max
	movl	%eax, -4(%rbp)
	movl	n(%rip), %edx
	movl	-8(%rbp), %eax
	movl	%edx, %r8d
	movl	$1, %ecx
	movl	$1, %edx
	movl	$0, %esi
	movl	%eax, %edi
	call	max_ren
	movl	%eax, %edx
	movl	-4(%rbp), %eax
	movl	%edx, %esi
	movl	%eax, %edi
	call	max
	movl	%eax, -4(%rbp)
	addl	$1, -8(%rbp)
.L13:
	movl	n(%rip), %eax
	cmpl	%eax, -8(%rbp)
	jl	.L14
	movl	$0, -8(%rbp)
	jmp	.L15
.L16:
	movl	n(%rip), %edx
	movl	n(%rip), %eax
	leal	-1(%rax), %esi
	movl	-8(%rbp), %eax
	movl	%edx, %r8d
	movl	$-1, %ecx
	movl	$1, %edx
	movl	%eax, %edi
	call	max_ren
	movl	%eax, %edx
	movl	-4(%rbp), %eax
	movl	%edx, %esi
	movl	%eax, %edi
	call	max
	movl	%eax, -4(%rbp)
	addl	$1, -8(%rbp)
.L15:
	movl	n(%rip), %eax
	cmpl	%eax, -8(%rbp)
	jl	.L16
	movl	-4(%rbp), %eax
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE2:
	.size	solve, .-solve
	.section	.rodata
.LC0:
	.string	"%s"
.LC1:
	.string	"%d\n"
.LC2:
	.string	"%d"
	.text
	.globl	main
	.type	main, @function
main:
.LFB3:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$16, %rsp
	jmp	.L19
.L23:
	movl	$0, -4(%rbp)
	jmp	.L20
.L21:
	movl	-4(%rbp), %eax
	cltq
	salq	$8, %rax
	movq	%rax, %rdx
	leaq	grid(%rip), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -4(%rbp)
.L20:
	movl	n(%rip), %eax
	cmpl	%eax, -4(%rbp)
	jl	.L21
	movl	$0, %eax
	call	solve
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L19:
	leaq	n(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	testl	%eax, %eax
	je	.L22
	movl	n(%rip), %eax
	testl	%eax, %eax
	jne	.L23
.L22:
	movl	$0, %eax
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE3:
	.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	max
	.type	max, @function
max:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	%edi, -4(%rbp)
	movl	%esi, -8(%rbp)
	movl	-8(%rbp), %edx
	movl	-4(%rbp), %eax
	cmpl	%eax, %edx
	cmovge	%edx, %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	max, .-max
	.globl	n
	.bss
	.align 4
	.type	n, @object
	.size	n, 4
n:
	.zero	4
	.globl	grid
	.align 32
	.type	grid, @object
	.size	grid, 65280
grid:
	.zero	65280
	.text
	.globl	max_ren
	.type	max_ren, @function
max_ren:
.LFB1:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	%edi, -20(%rbp)
	movl	%esi, -24(%rbp)
	movl	%edx, -28(%rbp)
	movl	%ecx, -32(%rbp)
	movl	%r8d, -36(%rbp)
	movl	$0, -8(%rbp)
	movl	$0, -4(%rbp)
	movl	-20(%rbp), %eax
	movl	%eax, -16(%rbp)
	movl	-24(%rbp), %eax
	movl	%eax, -12(%rbp)
	jmp	.L4
.L8:
	movl	-12(%rbp), %eax
	movslq	%eax, %rdx
	movl	-16(%rbp), %eax
	cltq
	salq	$8, %rax
	addq	%rax, %rdx
	leaq	grid(%rip), %rax
	addq	%rdx, %rax
	movzbl	(%rax), %eax
	cmpb	$49, %al
	jne	.L5
	addl	$1, -8(%rbp)
	movl	-8(%rbp), %eax
	cmpl	-4(%rbp), %eax
	jle	.L6
	movl	-8(%rbp), %eax
	movl	%eax, -4(%rbp)
	jmp	.L6
.L5:
	movl	$0, -8(%rbp)
.L6:
	movl	-28(%rbp), %eax
	addl	%eax, -16(%rbp)
	movl	-32(%rbp), %eax
	addl	%eax, -12(%rbp)
.L4:
	movl	-16(%rbp), %eax
	cmpl	-36(%rbp), %eax
	jge	.L7
	cmpl	$0, -16(%rbp)
	js	.L7
	movl	-12(%rbp), %eax
	cmpl	-36(%rbp), %eax
	jge	.L7
	cmpl	$0, -12(%rbp)
	jns	.L8
.L7:
	movl	-4(%rbp), %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.size	max_ren, .-max_ren
	.globl	solve
	.type	solve, @function
solve:
.LFB2:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$16, %rsp
	movl	$0, -4(%rbp)
	movl	$0, -8(%rbp)
	jmp	.L11
.L12:
	movl	n(%rip), %edx
	movl	-8(%rbp), %eax
	movl	%edx, %r8d
	movl	$0, %ecx
	movl	$1, %edx
	movl	%eax, %esi
	movl	$0, %edi
	call	max_ren
	movl	%eax, %edx
	movl	-4(%rbp), %eax
	movl	%edx, %esi
	movl	%eax, %edi
	call	max
	movl	%eax, -4(%rbp)
	movl	n(%rip), %edx
	movl	-8(%rbp), %eax
	movl	%edx, %r8d
	movl	$1, %ecx
	movl	$1, %edx
	movl	%eax, %esi
	movl	$0, %edi
	call	max_ren
	movl	%eax, %edx
	movl	-4(%rbp), %eax
	movl	%edx, %esi
	movl	%eax, %edi
	call	max
	movl	%eax, -4(%rbp)
	movl	n(%rip), %edx
	movl	-8(%rbp), %eax
	movl	%edx, %r8d
	movl	$-1, %ecx
	movl	$1, %edx
	movl	%eax, %esi
	movl	$0, %edi
	call	max_ren
	movl	%eax, %edx
	movl	-4(%rbp), %eax
	movl	%edx, %esi
	movl	%eax, %edi
	call	max
	movl	%eax, -4(%rbp)
	addl	$1, -8(%rbp)
.L11:
	movl	n(%rip), %eax
	cmpl	%eax, -8(%rbp)
	jl	.L12
	movl	$0, -8(%rbp)
	jmp	.L13
.L14:
	movl	n(%rip), %edx
	movl	-8(%rbp), %eax
	movl	%edx, %r8d
	movl	$1, %ecx
	movl	$0, %edx
	movl	$0, %esi
	movl	%eax, %edi
	call	max_ren
	movl	%eax, %edx
	movl	-4(%rbp), %eax
	movl	%edx, %esi
	movl	%eax, %edi
	call	max
	movl	%eax, -4(%rbp)
	movl	n(%rip), %edx
	movl	-8(%rbp), %eax
	movl	%edx, %r8d
	movl	$1, %ecx
	movl	$1, %edx
	movl	$0, %esi
	movl	%eax, %edi
	call	max_ren
	movl	%eax, %edx
	movl	-4(%rbp), %eax
	movl	%edx, %esi
	movl	%eax, %edi
	call	max
	movl	%eax, -4(%rbp)
	addl	$1, -8(%rbp)
.L13:
	movl	n(%rip), %eax
	cmpl	%eax, -8(%rbp)
	jl	.L14
	movl	$0, -8(%rbp)
	jmp	.L15
.L16:
	movl	n(%rip), %edx
	movl	n(%rip), %eax
	leal	-1(%rax), %esi
	movl	-8(%rbp), %eax
	movl	%edx, %r8d
	movl	$-1, %ecx
	movl	$1, %edx
	movl	%eax, %edi
	call	max_ren
	movl	%eax, %edx
	movl	-4(%rbp), %eax
	movl	%edx, %esi
	movl	%eax, %edi
	call	max
	movl	%eax, -4(%rbp)
	addl	$1, -8(%rbp)
.L15:
	movl	n(%rip), %eax
	cmpl	%eax, -8(%rbp)
	jl	.L16
	movl	-4(%rbp), %eax
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE2:
	.size	solve, .-solve
	.section	.rodata
.LC0:
	.string	"%s"
.LC1:
	.string	"%d\n"
.LC2:
	.string	"%d"
	.text
	.globl	main
	.type	main, @function
main:
.LFB3:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$16, %rsp
	jmp	.L19
.L23:
	movl	$0, -4(%rbp)
	jmp	.L20
.L21:
	movl	-4(%rbp), %eax
	cltq
	salq	$8, %rax
	movq	%rax, %rdx
	leaq	grid(%rip), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -4(%rbp)
.L20:
	movl	n(%rip), %eax
	cmpl	%eax, -4(%rbp)
	jl	.L21
	movl	$0, %eax
	call	solve
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L19:
	leaq	n(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	testl	%eax, %eax
	je	.L22
	movl	n(%rip), %eax
	testl	%eax, %eax
	jne	.L23
.L22:
	movl	$0, %eax
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE3:
	.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:
