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>

#define N 255

int main() {
	char grid[N][N+1];
	int n;
	int i,j,k;
	int ones;
	int max_ones;
	
	while (1) {
		scanf("%d",&n);
		if (n == 0) {
			break;
		}
		for (i = 0;i != n;++i) {
			scanf("%s",grid[i]);
		}
		max_ones = 0;
		// horizontal
		for (i = 0;i < n;++i) {
			ones = 0;
			for (j = 0;j < n;++j) {
				if (grid[i][j] == '1') {
					++ones;
				} else {
					if (ones > max_ones) {
						max_ones = ones;
					}
					ones = 0;
				}
			}
			if (ones > max_ones) {
				max_ones = ones;
			}
		}
		// vertical
		for (j = 0;j < n;++j) {
			ones = 0;
			for (i = 0;i < n;++i) {
				if (grid[i][j] == '1') {
					++ones;
				} else {
					if (ones > max_ones) {
						max_ones = ones;
					}
					ones = 0;
				}
			}
			if (ones > max_ones) {
				max_ones = ones;
			}
		}
		// diagonal
		for (j = 0;j < n;++j) {
			ones = 0;
			for (i = 0,k = j;k >= 0;++i,--k) {
				if (grid[i][k] == '1') {
					++ones;
				} else {
					if (ones > max_ones) {
						max_ones = ones;
					}
					ones = 0;
				}
			}
			if (ones > max_ones) {
				max_ones = ones;
			}
		}
		for (i = 1;i < n;++i) {
			ones = 0;
			for (k = i,j = n-1;k < n;++k,--j) {
				if (grid[k][j] == '1') {
					++ones;
				} else {
					if (ones > max_ones) {
						max_ones = ones;
					}
					ones = 0;
				}
			}
			if (ones > max_ones) {
				max_ones = ones;
			}
		}
		for (j = 0;j < n;++j) {
			ones = 0;
			for (i = 0,k = j;k < n;++i,++k) {
				if (grid[i][k] == '1') {
					++ones;
				} else {
					if (ones > max_ones) {
						max_ones = ones;
					}
					ones = 0;
				}
			}
			if (ones > max_ones) {
				max_ones = ones;
			}
		}
		for (i = 1;i < n;++i) {
			ones = 0;
			for (k = i,j = 0;k < n;++k,++j) {
				if (grid[k][j] == '1') {
					++ones;
				} else {
					if (ones > max_ones) {
						max_ones = ones;
					}
					ones = 0;
				}
			}
			if (ones > max_ones) {
				max_ones = ones;
			}
		}
		printf("%d\n",max_ones);
	}
	return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%s"
.LC2:
	.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
	leaq	-61440(%rsp), %r11
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	subq	$3888, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
.L54:
	leaq	-65320(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-65320(%rbp), %eax
	testl	%eax, %eax
	je	.L58
	movl	$0, -65316(%rbp)
	jmp	.L4
.L5:
	leaq	-65296(%rbp), %rdx
	movl	-65316(%rbp), %eax
	cltq
	salq	$8, %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -65316(%rbp)
.L4:
	movl	-65320(%rbp), %eax
	cmpl	%eax, -65316(%rbp)
	jne	.L5
	movl	$0, -65300(%rbp)
	movl	$0, -65316(%rbp)
	jmp	.L6
.L13:
	movl	$0, -65304(%rbp)
	movl	$0, -65312(%rbp)
	jmp	.L7
.L11:
	movl	-65312(%rbp), %eax
	movslq	%eax, %rdx
	movl	-65316(%rbp), %eax
	cltq
	salq	$8, %rax
	addq	%rbp, %rax
	addq	%rdx, %rax
	subq	$65296, %rax
	movzbl	(%rax), %eax
	cmpb	$49, %al
	jne	.L8
	addl	$1, -65304(%rbp)
	jmp	.L9
.L8:
	movl	-65304(%rbp), %eax
	cmpl	-65300(%rbp), %eax
	jle	.L10
	movl	-65304(%rbp), %eax
	movl	%eax, -65300(%rbp)
.L10:
	movl	$0, -65304(%rbp)
.L9:
	addl	$1, -65312(%rbp)
.L7:
	movl	-65320(%rbp), %eax
	cmpl	%eax, -65312(%rbp)
	jl	.L11
	movl	-65304(%rbp), %eax
	cmpl	-65300(%rbp), %eax
	jle	.L12
	movl	-65304(%rbp), %eax
	movl	%eax, -65300(%rbp)
.L12:
	addl	$1, -65316(%rbp)
.L6:
	movl	-65320(%rbp), %eax
	cmpl	%eax, -65316(%rbp)
	jl	.L13
	movl	$0, -65312(%rbp)
	jmp	.L14
.L21:
	movl	$0, -65304(%rbp)
	movl	$0, -65316(%rbp)
	jmp	.L15
.L19:
	movl	-65312(%rbp), %eax
	movslq	%eax, %rdx
	movl	-65316(%rbp), %eax
	cltq
	salq	$8, %rax
	addq	%rbp, %rax
	addq	%rdx, %rax
	subq	$65296, %rax
	movzbl	(%rax), %eax
	cmpb	$49, %al
	jne	.L16
	addl	$1, -65304(%rbp)
	jmp	.L17
.L16:
	movl	-65304(%rbp), %eax
	cmpl	-65300(%rbp), %eax
	jle	.L18
	movl	-65304(%rbp), %eax
	movl	%eax, -65300(%rbp)
.L18:
	movl	$0, -65304(%rbp)
.L17:
	addl	$1, -65316(%rbp)
.L15:
	movl	-65320(%rbp), %eax
	cmpl	%eax, -65316(%rbp)
	jl	.L19
	movl	-65304(%rbp), %eax
	cmpl	-65300(%rbp), %eax
	jle	.L20
	movl	-65304(%rbp), %eax
	movl	%eax, -65300(%rbp)
.L20:
	addl	$1, -65312(%rbp)
.L14:
	movl	-65320(%rbp), %eax
	cmpl	%eax, -65312(%rbp)
	jl	.L21
	movl	$0, -65312(%rbp)
	jmp	.L22
.L29:
	movl	$0, -65304(%rbp)
	movl	$0, -65316(%rbp)
	movl	-65312(%rbp), %eax
	movl	%eax, -65308(%rbp)
	jmp	.L23
.L27:
	movl	-65308(%rbp), %eax
	movslq	%eax, %rdx
	movl	-65316(%rbp), %eax
	cltq
	salq	$8, %rax
	addq	%rbp, %rax
	addq	%rdx, %rax
	subq	$65296, %rax
	movzbl	(%rax), %eax
	cmpb	$49, %al
	jne	.L24
	addl	$1, -65304(%rbp)
	jmp	.L25
.L24:
	movl	-65304(%rbp), %eax
	cmpl	-65300(%rbp), %eax
	jle	.L26
	movl	-65304(%rbp), %eax
	movl	%eax, -65300(%rbp)
.L26:
	movl	$0, -65304(%rbp)
.L25:
	addl	$1, -65316(%rbp)
	subl	$1, -65308(%rbp)
.L23:
	cmpl	$0, -65308(%rbp)
	jns	.L27
	movl	-65304(%rbp), %eax
	cmpl	-65300(%rbp), %eax
	jle	.L28
	movl	-65304(%rbp), %eax
	movl	%eax, -65300(%rbp)
.L28:
	addl	$1, -65312(%rbp)
.L22:
	movl	-65320(%rbp), %eax
	cmpl	%eax, -65312(%rbp)
	jl	.L29
	movl	$1, -65316(%rbp)
	jmp	.L30
.L37:
	movl	$0, -65304(%rbp)
	movl	-65316(%rbp), %eax
	movl	%eax, -65308(%rbp)
	movl	-65320(%rbp), %eax
	subl	$1, %eax
	movl	%eax, -65312(%rbp)
	jmp	.L31
.L35:
	movl	-65312(%rbp), %eax
	movslq	%eax, %rdx
	movl	-65308(%rbp), %eax
	cltq
	salq	$8, %rax
	addq	%rbp, %rax
	addq	%rdx, %rax
	subq	$65296, %rax
	movzbl	(%rax), %eax
	cmpb	$49, %al
	jne	.L32
	addl	$1, -65304(%rbp)
	jmp	.L33
.L32:
	movl	-65304(%rbp), %eax
	cmpl	-65300(%rbp), %eax
	jle	.L34
	movl	-65304(%rbp), %eax
	movl	%eax, -65300(%rbp)
.L34:
	movl	$0, -65304(%rbp)
.L33:
	addl	$1, -65308(%rbp)
	subl	$1, -65312(%rbp)
.L31:
	movl	-65320(%rbp), %eax
	cmpl	%eax, -65308(%rbp)
	jl	.L35
	movl	-65304(%rbp), %eax
	cmpl	-65300(%rbp), %eax
	jle	.L36
	movl	-65304(%rbp), %eax
	movl	%eax, -65300(%rbp)
.L36:
	addl	$1, -65316(%rbp)
.L30:
	movl	-65320(%rbp), %eax
	cmpl	%eax, -65316(%rbp)
	jl	.L37
	movl	$0, -65312(%rbp)
	jmp	.L38
.L45:
	movl	$0, -65304(%rbp)
	movl	$0, -65316(%rbp)
	movl	-65312(%rbp), %eax
	movl	%eax, -65308(%rbp)
	jmp	.L39
.L43:
	movl	-65308(%rbp), %eax
	movslq	%eax, %rdx
	movl	-65316(%rbp), %eax
	cltq
	salq	$8, %rax
	addq	%rbp, %rax
	addq	%rdx, %rax
	subq	$65296, %rax
	movzbl	(%rax), %eax
	cmpb	$49, %al
	jne	.L40
	addl	$1, -65304(%rbp)
	jmp	.L41
.L40:
	movl	-65304(%rbp), %eax
	cmpl	-65300(%rbp), %eax
	jle	.L42
	movl	-65304(%rbp), %eax
	movl	%eax, -65300(%rbp)
.L42:
	movl	$0, -65304(%rbp)
.L41:
	addl	$1, -65316(%rbp)
	addl	$1, -65308(%rbp)
.L39:
	movl	-65320(%rbp), %eax
	cmpl	%eax, -65308(%rbp)
	jl	.L43
	movl	-65304(%rbp), %eax
	cmpl	-65300(%rbp), %eax
	jle	.L44
	movl	-65304(%rbp), %eax
	movl	%eax, -65300(%rbp)
.L44:
	addl	$1, -65312(%rbp)
.L38:
	movl	-65320(%rbp), %eax
	cmpl	%eax, -65312(%rbp)
	jl	.L45
	movl	$1, -65316(%rbp)
	jmp	.L46
.L53:
	movl	$0, -65304(%rbp)
	movl	-65316(%rbp), %eax
	movl	%eax, -65308(%rbp)
	movl	$0, -65312(%rbp)
	jmp	.L47
.L51:
	movl	-65312(%rbp), %eax
	movslq	%eax, %rdx
	movl	-65308(%rbp), %eax
	cltq
	salq	$8, %rax
	addq	%rbp, %rax
	addq	%rdx, %rax
	subq	$65296, %rax
	movzbl	(%rax), %eax
	cmpb	$49, %al
	jne	.L48
	addl	$1, -65304(%rbp)
	jmp	.L49
.L48:
	movl	-65304(%rbp), %eax
	cmpl	-65300(%rbp), %eax
	jle	.L50
	movl	-65304(%rbp), %eax
	movl	%eax, -65300(%rbp)
.L50:
	movl	$0, -65304(%rbp)
.L49:
	addl	$1, -65308(%rbp)
	addl	$1, -65312(%rbp)
.L47:
	movl	-65320(%rbp), %eax
	cmpl	%eax, -65308(%rbp)
	jl	.L51
	movl	-65304(%rbp), %eax
	cmpl	-65300(%rbp), %eax
	jle	.L52
	movl	-65304(%rbp), %eax
	movl	%eax, -65300(%rbp)
.L52:
	addl	$1, -65316(%rbp)
.L46:
	movl	-65320(%rbp), %eax
	cmpl	%eax, -65316(%rbp)
	jl	.L53
	movl	-65300(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L54
.L58:
	nop
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L56
	call	__stack_chk_fail@PLT
.L56:
	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	"%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
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	leaq	-61440(%rsp), %r11
	.cfi_def_cfa 11, 61496
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	.cfi_def_cfa_register 7
	subq	$3880, %rsp
	.cfi_def_cfa_offset 65376
	leaq	.LC1(%rip), %rbp
	movq	%fs:40, %rax
	movq	%rax, 65304(%rsp)
	xorl	%eax, %eax
	leaq	12(%rsp), %r14
	leaq	16(%rsp), %r12
	.p2align 4,,10
	.p2align 3
.L52:
	movq	%r14, %rsi
	leaq	.LC0(%rip), %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	12(%rsp), %eax
	testl	%eax, %eax
	je	.L2
	movq	%r12, %rbx
	movq	%r12, %r15
	xorl	%r13d, %r13d
	.p2align 4,,10
	.p2align 3
.L3:
	movq	%r15, %rsi
	movq	%rbp, %rdi
	xorl	%eax, %eax
	addq	$256, %r15
	call	__isoc99_scanf@PLT
	movl	%r13d, %ecx
	addl	$1, %r13d
	cmpl	%r13d, 12(%rsp)
	jne	.L3
	movslq	%ecx, %r8
	leaq	1(%r12), %rsi
	xorl	%edx, %edx
	movq	%r8, %rax
	leaq	(%rsi,%r8), %r10
	salq	$8, %rax
	addq	%r8, %rax
	leaq	257(%r12,%rax), %r9
	.p2align 4,,10
	.p2align 3
.L7:
	movq	%r10, %rax
	xorl	%edi, %edi
	subq	%r8, %rax
	subq	$1, %rax
	jmp	.L6
	.p2align 4,,10
	.p2align 3
.L75:
	cmpl	%edi, %edx
	cmovl	%edi, %edx
	addq	$1, %rax
	xorl	%edi, %edi
	cmpq	%rax, %r10
	je	.L74
.L6:
	cmpb	$49, (%rax)
	jne	.L75
	addq	$1, %rax
	addl	$1, %edi
	cmpq	%rax, %r10
	jne	.L6
.L74:
	cmpl	%edi, %edx
	cmovl	%edi, %edx
	addq	$256, %r10
	cmpq	%r10, %r9
	jne	.L7
	movq	%r8, %rax
	movq	$-256, %r11
	salq	$8, %rax
	leaq	256(%r12,%rax), %r10
	subq	%rax, %r11
	.p2align 4,,10
	.p2align 3
.L11:
	leaq	(%r11,%r10), %rax
	xorl	%edi, %edi
	jmp	.L10
	.p2align 4,,10
	.p2align 3
.L77:
	cmpl	%edi, %edx
	cmovl	%edi, %edx
	addq	$256, %rax
	xorl	%edi, %edi
	cmpq	%rax, %r10
	je	.L76
.L10:
	cmpb	$49, (%rax)
	jne	.L77
	addq	$256, %rax
	addl	$1, %edi
	cmpq	%rax, %r10
	jne	.L10
.L76:
	cmpl	%edi, %edx
	cmovl	%edi, %edx
	addq	$1, %r10
	cmpq	%r9, %r10
	jne	.L11
	leaq	255(%r12), %r9
	movq	%r12, %r10
	xorl	%r11d, %r11d
	.p2align 4,,10
	.p2align 3
.L15:
	movq	%r10, %rax
	xorl	%edi, %edi
	jmp	.L14
	.p2align 4,,10
	.p2align 3
.L79:
	cmpl	%edi, %edx
	cmovl	%edi, %edx
	addq	$255, %rax
	xorl	%edi, %edi
	cmpq	%rax, %r9
	je	.L78
.L14:
	cmpb	$49, (%rax)
	jne	.L79
	addq	$255, %rax
	addl	$1, %edi
	cmpq	%rax, %r9
	jne	.L14
.L78:
	cmpl	%edi, %edx
	leal	1(%r11), %eax
	cmovl	%edi, %edx
	addq	$256, %r9
	addq	$1, %r10
	cmpl	%r11d, %ecx
	je	.L80
	movl	%eax, %r11d
	jmp	.L15
	.p2align 4,,10
	.p2align 3
.L80:
	cmpl	$1, %r13d
	je	.L16
	leaq	256(%r12,%r8), %r11
	movl	$1, %r10d
	.p2align 4,,10
	.p2align 3
.L17:
	movq	%r11, %rax
	movl	%r10d, %r8d
	xorl	%edi, %edi
	jmp	.L21
	.p2align 4,,10
	.p2align 3
.L82:
	cmpl	%edi, %edx
	leal	1(%r8), %r9d
	cmovl	%edi, %edx
	xorl	%edi, %edi
	addq	$255, %rax
	cmpl	%r8d, %ecx
	jle	.L81
.L55:
	movl	%r9d, %r8d
.L21:
	cmpb	$49, (%rax)
	jne	.L82
	addl	$1, %edi
	leal	1(%r8), %r9d
	addq	$255, %rax
	cmpl	%r8d, %ecx
	jg	.L55
.L81:
	cmpl	%edi, %edx
	leal	1(%r10), %eax
	cmovl	%edi, %edx
	addq	$256, %r11
	cmpl	%r10d, %ecx
	je	.L16
	movl	%eax, %r10d
	jmp	.L17
	.p2align 4,,10
	.p2align 3
.L16:
	xorl	%r9d, %r9d
	.p2align 4,,10
	.p2align 3
.L31:
	movl	%r9d, %edi
	xorl	%eax, %eax
	jmp	.L30
	.p2align 4,,10
	.p2align 3
.L84:
	cmpl	%eax, %edx
	leal	1(%rdi), %r8d
	cmovl	%eax, %edx
	xorl	%eax, %eax
	addq	$257, %rbx
	cmpl	%ecx, %edi
	jge	.L83
.L57:
	movl	%r8d, %edi
.L30:
	cmpb	$49, (%rbx)
	jne	.L84
	addl	$1, %eax
	leal	1(%rdi), %r8d
	addq	$257, %rbx
	cmpl	%ecx, %edi
	jl	.L57
.L83:
	cmpl	%eax, %edx
	movq	%rsi, %rbx
	cmovl	%eax, %edx
	leal	1(%r9), %eax
	cmpl	%r9d, %ecx
	je	.L85
	movl	%eax, %r9d
	addq	$1, %rsi
	jmp	.L31
	.p2align 4,,10
	.p2align 3
.L85:
	leaq	272(%rsp), %r10
	movl	$1, %r9d
	cmpl	$1, %r13d
	je	.L40
	.p2align 4,,10
	.p2align 3
.L45:
	movq	%r10, %rax
	movl	%r9d, %edi
	xorl	%esi, %esi
	jmp	.L44
	.p2align 4,,10
	.p2align 3
.L87:
	cmpl	%esi, %edx
	leal	1(%rdi), %r8d
	cmovl	%esi, %edx
	xorl	%esi, %esi
	addq	$257, %rax
	cmpl	%edi, %ecx
	jle	.L86
.L59:
	movl	%r8d, %edi
.L44:
	cmpb	$49, (%rax)
	jne	.L87
	addl	$1, %esi
	leal	1(%rdi), %r8d
	addq	$257, %rax
	cmpl	%edi, %ecx
	jg	.L59
.L86:
	cmpl	%esi, %edx
	leal	1(%r9), %eax
	cmovl	%esi, %edx
	addq	$256, %r10
	cmpl	%r9d, %ecx
	je	.L40
	movl	%eax, %r9d
	jmp	.L45
	.p2align 4,,10
	.p2align 3
.L40:
	leaq	.LC2(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L52
.L2:
	movq	65304(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L88
	addq	$65320, %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
.L88:
	.cfi_restore_state
	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	"%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
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	leaq	-61440(%rsp), %r11
	.cfi_def_cfa 11, 61496
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	.cfi_def_cfa_register 7
	subq	$3880, %rsp
	.cfi_def_cfa_offset 65376
	leaq	.LC1(%rip), %rbp
	movq	%fs:40, %rax
	movq	%rax, 65304(%rsp)
	xorl	%eax, %eax
	leaq	12(%rsp), %r14
	leaq	16(%rsp), %r12
	.p2align 4,,10
	.p2align 3
.L52:
	movq	%r14, %rsi
	leaq	.LC0(%rip), %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	12(%rsp), %eax
	testl	%eax, %eax
	je	.L2
	movq	%r12, %rbx
	movq	%r12, %r15
	xorl	%r13d, %r13d
	.p2align 4,,10
	.p2align 3
.L3:
	movq	%r15, %rsi
	movq	%rbp, %rdi
	xorl	%eax, %eax
	addq	$256, %r15
	call	__isoc99_scanf@PLT
	movl	%r13d, %ecx
	addl	$1, %r13d
	cmpl	%r13d, 12(%rsp)
	jne	.L3
	movslq	%ecx, %r8
	leaq	1(%r12), %rsi
	xorl	%edx, %edx
	movq	%r8, %rax
	leaq	(%rsi,%r8), %r10
	salq	$8, %rax
	addq	%r8, %rax
	leaq	257(%r12,%rax), %r9
	.p2align 4,,10
	.p2align 3
.L7:
	movq	%r10, %rax
	xorl	%edi, %edi
	subq	%r8, %rax
	subq	$1, %rax
	jmp	.L6
	.p2align 4,,10
	.p2align 3
.L75:
	cmpl	%edi, %edx
	cmovl	%edi, %edx
	addq	$1, %rax
	xorl	%edi, %edi
	cmpq	%rax, %r10
	je	.L74
.L6:
	cmpb	$49, (%rax)
	jne	.L75
	addq	$1, %rax
	addl	$1, %edi
	cmpq	%rax, %r10
	jne	.L6
.L74:
	cmpl	%edi, %edx
	cmovl	%edi, %edx
	addq	$256, %r10
	cmpq	%r10, %r9
	jne	.L7
	movq	%r8, %rax
	movq	$-256, %r11
	salq	$8, %rax
	leaq	256(%r12,%rax), %r10
	subq	%rax, %r11
	.p2align 4,,10
	.p2align 3
.L11:
	leaq	(%r11,%r10), %rax
	xorl	%edi, %edi
	jmp	.L10
	.p2align 4,,10
	.p2align 3
.L77:
	cmpl	%edi, %edx
	cmovl	%edi, %edx
	addq	$256, %rax
	xorl	%edi, %edi
	cmpq	%rax, %r10
	je	.L76
.L10:
	cmpb	$49, (%rax)
	jne	.L77
	addq	$256, %rax
	addl	$1, %edi
	cmpq	%rax, %r10
	jne	.L10
.L76:
	cmpl	%edi, %edx
	cmovl	%edi, %edx
	addq	$1, %r10
	cmpq	%r9, %r10
	jne	.L11
	leaq	255(%r12), %r9
	movq	%r12, %r10
	xorl	%r11d, %r11d
	.p2align 4,,10
	.p2align 3
.L15:
	movq	%r10, %rax
	xorl	%edi, %edi
	jmp	.L14
	.p2align 4,,10
	.p2align 3
.L79:
	cmpl	%edi, %edx
	cmovl	%edi, %edx
	addq	$255, %rax
	xorl	%edi, %edi
	cmpq	%rax, %r9
	je	.L78
.L14:
	cmpb	$49, (%rax)
	jne	.L79
	addq	$255, %rax
	addl	$1, %edi
	cmpq	%rax, %r9
	jne	.L14
.L78:
	cmpl	%edi, %edx
	leal	1(%r11), %eax
	cmovl	%edi, %edx
	addq	$256, %r9
	addq	$1, %r10
	cmpl	%r11d, %ecx
	je	.L80
	movl	%eax, %r11d
	jmp	.L15
	.p2align 4,,10
	.p2align 3
.L80:
	cmpl	$1, %r13d
	je	.L16
	leaq	256(%r12,%r8), %r11
	movl	$1, %r10d
	.p2align 4,,10
	.p2align 3
.L17:
	movq	%r11, %rax
	movl	%r10d, %r8d
	xorl	%edi, %edi
	jmp	.L21
	.p2align 4,,10
	.p2align 3
.L82:
	cmpl	%edi, %edx
	leal	1(%r8), %r9d
	cmovl	%edi, %edx
	xorl	%edi, %edi
	addq	$255, %rax
	cmpl	%r8d, %ecx
	jle	.L81
.L55:
	movl	%r9d, %r8d
.L21:
	cmpb	$49, (%rax)
	jne	.L82
	addl	$1, %edi
	leal	1(%r8), %r9d
	addq	$255, %rax
	cmpl	%r8d, %ecx
	jg	.L55
.L81:
	cmpl	%edi, %edx
	leal	1(%r10), %eax
	cmovl	%edi, %edx
	addq	$256, %r11
	cmpl	%r10d, %ecx
	je	.L16
	movl	%eax, %r10d
	jmp	.L17
	.p2align 4,,10
	.p2align 3
.L16:
	xorl	%r9d, %r9d
	.p2align 4,,10
	.p2align 3
.L31:
	movl	%r9d, %edi
	xorl	%eax, %eax
	jmp	.L30
	.p2align 4,,10
	.p2align 3
.L84:
	cmpl	%eax, %edx
	leal	1(%rdi), %r8d
	cmovl	%eax, %edx
	xorl	%eax, %eax
	addq	$257, %rbx
	cmpl	%ecx, %edi
	jge	.L83
.L57:
	movl	%r8d, %edi
.L30:
	cmpb	$49, (%rbx)
	jne	.L84
	addl	$1, %eax
	leal	1(%rdi), %r8d
	addq	$257, %rbx
	cmpl	%ecx, %edi
	jl	.L57
.L83:
	cmpl	%eax, %edx
	movq	%rsi, %rbx
	cmovl	%eax, %edx
	leal	1(%r9), %eax
	cmpl	%r9d, %ecx
	je	.L85
	movl	%eax, %r9d
	addq	$1, %rsi
	jmp	.L31
	.p2align 4,,10
	.p2align 3
.L85:
	leaq	272(%rsp), %r10
	movl	$1, %r9d
	cmpl	$1, %r13d
	je	.L40
	.p2align 4,,10
	.p2align 3
.L45:
	movq	%r10, %rax
	movl	%r9d, %edi
	xorl	%esi, %esi
	jmp	.L44
	.p2align 4,,10
	.p2align 3
.L87:
	cmpl	%esi, %edx
	leal	1(%rdi), %r8d
	cmovl	%esi, %edx
	xorl	%esi, %esi
	addq	$257, %rax
	cmpl	%edi, %ecx
	jle	.L86
.L59:
	movl	%r8d, %edi
.L44:
	cmpb	$49, (%rax)
	jne	.L87
	addl	$1, %esi
	leal	1(%rdi), %r8d
	addq	$257, %rax
	cmpl	%edi, %ecx
	jg	.L59
.L86:
	cmpl	%esi, %edx
	leal	1(%r9), %eax
	cmovl	%esi, %edx
	addq	$256, %r10
	cmpl	%r9d, %ecx
	je	.L40
	movl	%eax, %r9d
	jmp	.L45
	.p2align 4,,10
	.p2align 3
.L40:
	leaq	.LC2(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L52
.L2:
	movq	65304(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L88
	addq	$65320, %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
.L88:
	.cfi_restore_state
	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>

#define N 255

int main() {
	char grid[N][N+1];
	int n;
	int i,j,k;
	int ones;
	int max_ones;
	
	while (1) {
		scanf("%d",&n);
		if (n == 0) {
			break;
		}
		for (i = 0;i != n;++i) {
			scanf("%s",grid[i]);
		}
		max_ones = 0;
		// horizontal
		for (i = 0;i < n;++i) {
			ones = 0;
			for (j = 0;j < n;++j) {
				if (grid[i][j] == '1') {
					++ones;
				} else {
					if (ones > max_ones) {
						max_ones = ones;
					}
					ones = 0;
				}
			}
			if (ones > max_ones) {
				max_ones = ones;
			}
		}
		// vertical
		for (j = 0;j < n;++j) {
			ones = 0;
			for (i = 0;i < n;++i) {
				if (grid[i][j] == '1') {
					++ones;
				} else {
					if (ones > max_ones) {
						max_ones = ones;
					}
					ones = 0;
				}
			}
			if (ones > max_ones) {
				max_ones = ones;
			}
		}
		// diagonal
		for (j = 0;j < n;++j) {
			ones = 0;
			for (i = 0,k = j;k >= 0;++i,--k) {
				if (grid[i][k] == '1') {
					++ones;
				} else {
					if (ones > max_ones) {
						max_ones = ones;
					}
					ones = 0;
				}
			}
			if (ones > max_ones) {
				max_ones = ones;
			}
		}
		for (i = 1;i < n;++i) {
			ones = 0;
			for (k = i,j = n-1;k < n;++k,--j) {
				if (grid[k][j] == '1') {
					++ones;
				} else {
					if (ones > max_ones) {
						max_ones = ones;
					}
					ones = 0;
				}
			}
			if (ones > max_ones) {
				max_ones = ones;
			}
		}
		for (j = 0;j < n;++j) {
			ones = 0;
			for (i = 0,k = j;k < n;++i,++k) {
				if (grid[i][k] == '1') {
					++ones;
				} else {
					if (ones > max_ones) {
						max_ones = ones;
					}
					ones = 0;
				}
			}
			if (ones > max_ones) {
				max_ones = ones;
			}
		}
		for (i = 1;i < n;++i) {
			ones = 0;
			for (k = i,j = 0;k < n;++k,++j) {
				if (grid[k][j] == '1') {
					++ones;
				} else {
					if (ones > max_ones) {
						max_ones = ones;
					}
					ones = 0;
				}
			}
			if (ones > max_ones) {
				max_ones = ones;
			}
		}
		printf("%d\n",max_ones);
	}
	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
#include <stdio.h>

#define N 255

int main() {
	char grid[N][N+1];
	int n;
	int i,j,k;
	int ones;
	int max_ones;
	
	while (1) {
		scanf("%d",&n);
		if (n == 0) {
			break;
		}
		for (i = 0;i != n;++i) {
			scanf("%s",grid[i]);
		}
		max_ones = 0;
		// horizontal
		for (i = 0;i < n;++i) {
			ones = 0;
			for (j = 0;j < n;++j) {
				if (grid[i][j] == '1') {
					++ones;
				} else {
					if (ones > max_ones) {
						max_ones = ones;
					}
					ones = 0;
				}
			}
			if (ones > max_ones) {
				max_ones = ones;
			}
		}
		// vertical
		for (j = 0;j < n;++j) {
			ones = 0;
			for (i = 0;i < n;++i) {
				if (grid[i][j] == '1') {
					++ones;
				} else {
					if (ones > max_ones) {
						max_ones = ones;
					}
					ones = 0;
				}
			}
			if (ones > max_ones) {
				max_ones = ones;
			}
		}
		// diagonal
		for (j = 0;j < n;++j) {
			ones = 0;
			for (i = 0,k = j;k >= 0;++i,--k) {
				if (grid[i][k] == '1') {
					++ones;
				} else {
					if (ones > max_ones) {
						max_ones = ones;
					}
					ones = 0;
				}
			}
			if (ones > max_ones) {
				max_ones = ones;
			}
		}
		for (i = 1;i < n;++i) {
			ones = 0;
			for (k = i,j = n-1;k < n;++k,--j) {
				if (grid[k][j] == '1') {
					++ones;
				} else {
					if (ones > max_ones) {
						max_ones = ones;
					}
					ones = 0;
				}
			}
			if (ones > max_ones) {
				max_ones = ones;
			}
		}
		for (j = 0;j < n;++j) {
			ones = 0;
			for (i = 0,k = j;k < n;++i,++k) {
				if (grid[i][k] == '1') {
					++ones;
				} else {
					if (ones > max_ones) {
						max_ones = ones;
					}
					ones = 0;
				}
			}
			if (ones > max_ones) {
				max_ones = ones;
			}
		}
		for (i = 1;i < n;++i) {
			ones = 0;
			for (k = i,j = 0;k < n;++k,++j) {
				if (grid[k][j] == '1') {
					++ones;
				} else {
					if (ones > max_ones) {
						max_ones = ones;
					}
					ones = 0;
				}
			}
			if (ones > max_ones) {
				max_ones = ones;
			}
		}
		printf("%d\n",max_ones);
	}
	return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%s"
.LC2:
	.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
	leaq	-61440(%rsp), %r11
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	subq	$3888, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
.L54:
	leaq	-65320(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-65320(%rbp), %eax
	testl	%eax, %eax
	je	.L58
	movl	$0, -65316(%rbp)
	jmp	.L4
.L5:
	leaq	-65296(%rbp), %rdx
	movl	-65316(%rbp), %eax
	cltq
	salq	$8, %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -65316(%rbp)
.L4:
	movl	-65320(%rbp), %eax
	cmpl	%eax, -65316(%rbp)
	jne	.L5
	movl	$0, -65300(%rbp)
	movl	$0, -65316(%rbp)
	jmp	.L6
.L13:
	movl	$0, -65304(%rbp)
	movl	$0, -65312(%rbp)
	jmp	.L7
.L11:
	movl	-65312(%rbp), %eax
	movslq	%eax, %rdx
	movl	-65316(%rbp), %eax
	cltq
	salq	$8, %rax
	addq	%rbp, %rax
	addq	%rdx, %rax
	subq	$65296, %rax
	movzbl	(%rax), %eax
	cmpb	$49, %al
	jne	.L8
	addl	$1, -65304(%rbp)
	jmp	.L9
.L8:
	movl	-65304(%rbp), %eax
	cmpl	-65300(%rbp), %eax
	jle	.L10
	movl	-65304(%rbp), %eax
	movl	%eax, -65300(%rbp)
.L10:
	movl	$0, -65304(%rbp)
.L9:
	addl	$1, -65312(%rbp)
.L7:
	movl	-65320(%rbp), %eax
	cmpl	%eax, -65312(%rbp)
	jl	.L11
	movl	-65304(%rbp), %eax
	cmpl	-65300(%rbp), %eax
	jle	.L12
	movl	-65304(%rbp), %eax
	movl	%eax, -65300(%rbp)
.L12:
	addl	$1, -65316(%rbp)
.L6:
	movl	-65320(%rbp), %eax
	cmpl	%eax, -65316(%rbp)
	jl	.L13
	movl	$0, -65312(%rbp)
	jmp	.L14
.L21:
	movl	$0, -65304(%rbp)
	movl	$0, -65316(%rbp)
	jmp	.L15
.L19:
	movl	-65312(%rbp), %eax
	movslq	%eax, %rdx
	movl	-65316(%rbp), %eax
	cltq
	salq	$8, %rax
	addq	%rbp, %rax
	addq	%rdx, %rax
	subq	$65296, %rax
	movzbl	(%rax), %eax
	cmpb	$49, %al
	jne	.L16
	addl	$1, -65304(%rbp)
	jmp	.L17
.L16:
	movl	-65304(%rbp), %eax
	cmpl	-65300(%rbp), %eax
	jle	.L18
	movl	-65304(%rbp), %eax
	movl	%eax, -65300(%rbp)
.L18:
	movl	$0, -65304(%rbp)
.L17:
	addl	$1, -65316(%rbp)
.L15:
	movl	-65320(%rbp), %eax
	cmpl	%eax, -65316(%rbp)
	jl	.L19
	movl	-65304(%rbp), %eax
	cmpl	-65300(%rbp), %eax
	jle	.L20
	movl	-65304(%rbp), %eax
	movl	%eax, -65300(%rbp)
.L20:
	addl	$1, -65312(%rbp)
.L14:
	movl	-65320(%rbp), %eax
	cmpl	%eax, -65312(%rbp)
	jl	.L21
	movl	$0, -65312(%rbp)
	jmp	.L22
.L29:
	movl	$0, -65304(%rbp)
	movl	$0, -65316(%rbp)
	movl	-65312(%rbp), %eax
	movl	%eax, -65308(%rbp)
	jmp	.L23
.L27:
	movl	-65308(%rbp), %eax
	movslq	%eax, %rdx
	movl	-65316(%rbp), %eax
	cltq
	salq	$8, %rax
	addq	%rbp, %rax
	addq	%rdx, %rax
	subq	$65296, %rax
	movzbl	(%rax), %eax
	cmpb	$49, %al
	jne	.L24
	addl	$1, -65304(%rbp)
	jmp	.L25
.L24:
	movl	-65304(%rbp), %eax
	cmpl	-65300(%rbp), %eax
	jle	.L26
	movl	-65304(%rbp), %eax
	movl	%eax, -65300(%rbp)
.L26:
	movl	$0, -65304(%rbp)
.L25:
	addl	$1, -65316(%rbp)
	subl	$1, -65308(%rbp)
.L23:
	cmpl	$0, -65308(%rbp)
	jns	.L27
	movl	-65304(%rbp), %eax
	cmpl	-65300(%rbp), %eax
	jle	.L28
	movl	-65304(%rbp), %eax
	movl	%eax, -65300(%rbp)
.L28:
	addl	$1, -65312(%rbp)
.L22:
	movl	-65320(%rbp), %eax
	cmpl	%eax, -65312(%rbp)
	jl	.L29
	movl	$1, -65316(%rbp)
	jmp	.L30
.L37:
	movl	$0, -65304(%rbp)
	movl	-65316(%rbp), %eax
	movl	%eax, -65308(%rbp)
	movl	-65320(%rbp), %eax
	subl	$1, %eax
	movl	%eax, -65312(%rbp)
	jmp	.L31
.L35:
	movl	-65312(%rbp), %eax
	movslq	%eax, %rdx
	movl	-65308(%rbp), %eax
	cltq
	salq	$8, %rax
	addq	%rbp, %rax
	addq	%rdx, %rax
	subq	$65296, %rax
	movzbl	(%rax), %eax
	cmpb	$49, %al
	jne	.L32
	addl	$1, -65304(%rbp)
	jmp	.L33
.L32:
	movl	-65304(%rbp), %eax
	cmpl	-65300(%rbp), %eax
	jle	.L34
	movl	-65304(%rbp), %eax
	movl	%eax, -65300(%rbp)
.L34:
	movl	$0, -65304(%rbp)
.L33:
	addl	$1, -65308(%rbp)
	subl	$1, -65312(%rbp)
.L31:
	movl	-65320(%rbp), %eax
	cmpl	%eax, -65308(%rbp)
	jl	.L35
	movl	-65304(%rbp), %eax
	cmpl	-65300(%rbp), %eax
	jle	.L36
	movl	-65304(%rbp), %eax
	movl	%eax, -65300(%rbp)
.L36:
	addl	$1, -65316(%rbp)
.L30:
	movl	-65320(%rbp), %eax
	cmpl	%eax, -65316(%rbp)
	jl	.L37
	movl	$0, -65312(%rbp)
	jmp	.L38
.L45:
	movl	$0, -65304(%rbp)
	movl	$0, -65316(%rbp)
	movl	-65312(%rbp), %eax
	movl	%eax, -65308(%rbp)
	jmp	.L39
.L43:
	movl	-65308(%rbp), %eax
	movslq	%eax, %rdx
	movl	-65316(%rbp), %eax
	cltq
	salq	$8, %rax
	addq	%rbp, %rax
	addq	%rdx, %rax
	subq	$65296, %rax
	movzbl	(%rax), %eax
	cmpb	$49, %al
	jne	.L40
	addl	$1, -65304(%rbp)
	jmp	.L41
.L40:
	movl	-65304(%rbp), %eax
	cmpl	-65300(%rbp), %eax
	jle	.L42
	movl	-65304(%rbp), %eax
	movl	%eax, -65300(%rbp)
.L42:
	movl	$0, -65304(%rbp)
.L41:
	addl	$1, -65316(%rbp)
	addl	$1, -65308(%rbp)
.L39:
	movl	-65320(%rbp), %eax
	cmpl	%eax, -65308(%rbp)
	jl	.L43
	movl	-65304(%rbp), %eax
	cmpl	-65300(%rbp), %eax
	jle	.L44
	movl	-65304(%rbp), %eax
	movl	%eax, -65300(%rbp)
.L44:
	addl	$1, -65312(%rbp)
.L38:
	movl	-65320(%rbp), %eax
	cmpl	%eax, -65312(%rbp)
	jl	.L45
	movl	$1, -65316(%rbp)
	jmp	.L46
.L53:
	movl	$0, -65304(%rbp)
	movl	-65316(%rbp), %eax
	movl	%eax, -65308(%rbp)
	movl	$0, -65312(%rbp)
	jmp	.L47
.L51:
	movl	-65312(%rbp), %eax
	movslq	%eax, %rdx
	movl	-65308(%rbp), %eax
	cltq
	salq	$8, %rax
	addq	%rbp, %rax
	addq	%rdx, %rax
	subq	$65296, %rax
	movzbl	(%rax), %eax
	cmpb	$49, %al
	jne	.L48
	addl	$1, -65304(%rbp)
	jmp	.L49
.L48:
	movl	-65304(%rbp), %eax
	cmpl	-65300(%rbp), %eax
	jle	.L50
	movl	-65304(%rbp), %eax
	movl	%eax, -65300(%rbp)
.L50:
	movl	$0, -65304(%rbp)
.L49:
	addl	$1, -65308(%rbp)
	addl	$1, -65312(%rbp)
.L47:
	movl	-65320(%rbp), %eax
	cmpl	%eax, -65308(%rbp)
	jl	.L51
	movl	-65304(%rbp), %eax
	cmpl	-65300(%rbp), %eax
	jle	.L52
	movl	-65304(%rbp), %eax
	movl	%eax, -65300(%rbp)
.L52:
	addl	$1, -65316(%rbp)
.L46:
	movl	-65320(%rbp), %eax
	cmpl	%eax, -65316(%rbp)
	jl	.L53
	movl	-65300(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L54
.L58:
	nop
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L56
	call	__stack_chk_fail@PLT
.L56:
	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	"%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
	leaq	-61440(%rsp), %r11
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	subq	$3888, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
.L54:
	leaq	-65320(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-65320(%rbp), %eax
	testl	%eax, %eax
	je	.L58
	movl	$0, -65316(%rbp)
	jmp	.L4
.L5:
	leaq	-65296(%rbp), %rdx
	movl	-65316(%rbp), %eax
	cltq
	salq	$8, %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -65316(%rbp)
.L4:
	movl	-65320(%rbp), %eax
	cmpl	%eax, -65316(%rbp)
	jne	.L5
	movl	$0, -65300(%rbp)
	movl	$0, -65316(%rbp)
	jmp	.L6
.L13:
	movl	$0, -65304(%rbp)
	movl	$0, -65312(%rbp)
	jmp	.L7
.L11:
	movl	-65312(%rbp), %eax
	movslq	%eax, %rdx
	movl	-65316(%rbp), %eax
	cltq
	salq	$8, %rax
	addq	%rbp, %rax
	addq	%rdx, %rax
	subq	$65296, %rax
	movzbl	(%rax), %eax
	cmpb	$49, %al
	jne	.L8
	addl	$1, -65304(%rbp)
	jmp	.L9
.L8:
	movl	-65304(%rbp), %eax
	cmpl	-65300(%rbp), %eax
	jle	.L10
	movl	-65304(%rbp), %eax
	movl	%eax, -65300(%rbp)
.L10:
	movl	$0, -65304(%rbp)
.L9:
	addl	$1, -65312(%rbp)
.L7:
	movl	-65320(%rbp), %eax
	cmpl	%eax, -65312(%rbp)
	jl	.L11
	movl	-65304(%rbp), %eax
	cmpl	-65300(%rbp), %eax
	jle	.L12
	movl	-65304(%rbp), %eax
	movl	%eax, -65300(%rbp)
.L12:
	addl	$1, -65316(%rbp)
.L6:
	movl	-65320(%rbp), %eax
	cmpl	%eax, -65316(%rbp)
	jl	.L13
	movl	$0, -65312(%rbp)
	jmp	.L14
.L21:
	movl	$0, -65304(%rbp)
	movl	$0, -65316(%rbp)
	jmp	.L15
.L19:
	movl	-65312(%rbp), %eax
	movslq	%eax, %rdx
	movl	-65316(%rbp), %eax
	cltq
	salq	$8, %rax
	addq	%rbp, %rax
	addq	%rdx, %rax
	subq	$65296, %rax
	movzbl	(%rax), %eax
	cmpb	$49, %al
	jne	.L16
	addl	$1, -65304(%rbp)
	jmp	.L17
.L16:
	movl	-65304(%rbp), %eax
	cmpl	-65300(%rbp), %eax
	jle	.L18
	movl	-65304(%rbp), %eax
	movl	%eax, -65300(%rbp)
.L18:
	movl	$0, -65304(%rbp)
.L17:
	addl	$1, -65316(%rbp)
.L15:
	movl	-65320(%rbp), %eax
	cmpl	%eax, -65316(%rbp)
	jl	.L19
	movl	-65304(%rbp), %eax
	cmpl	-65300(%rbp), %eax
	jle	.L20
	movl	-65304(%rbp), %eax
	movl	%eax, -65300(%rbp)
.L20:
	addl	$1, -65312(%rbp)
.L14:
	movl	-65320(%rbp), %eax
	cmpl	%eax, -65312(%rbp)
	jl	.L21
	movl	$0, -65312(%rbp)
	jmp	.L22
.L29:
	movl	$0, -65304(%rbp)
	movl	$0, -65316(%rbp)
	movl	-65312(%rbp), %eax
	movl	%eax, -65308(%rbp)
	jmp	.L23
.L27:
	movl	-65308(%rbp), %eax
	movslq	%eax, %rdx
	movl	-65316(%rbp), %eax
	cltq
	salq	$8, %rax
	addq	%rbp, %rax
	addq	%rdx, %rax
	subq	$65296, %rax
	movzbl	(%rax), %eax
	cmpb	$49, %al
	jne	.L24
	addl	$1, -65304(%rbp)
	jmp	.L25
.L24:
	movl	-65304(%rbp), %eax
	cmpl	-65300(%rbp), %eax
	jle	.L26
	movl	-65304(%rbp), %eax
	movl	%eax, -65300(%rbp)
.L26:
	movl	$0, -65304(%rbp)
.L25:
	addl	$1, -65316(%rbp)
	subl	$1, -65308(%rbp)
.L23:
	cmpl	$0, -65308(%rbp)
	jns	.L27
	movl	-65304(%rbp), %eax
	cmpl	-65300(%rbp), %eax
	jle	.L28
	movl	-65304(%rbp), %eax
	movl	%eax, -65300(%rbp)
.L28:
	addl	$1, -65312(%rbp)
.L22:
	movl	-65320(%rbp), %eax
	cmpl	%eax, -65312(%rbp)
	jl	.L29
	movl	$1, -65316(%rbp)
	jmp	.L30
.L37:
	movl	$0, -65304(%rbp)
	movl	-65316(%rbp), %eax
	movl	%eax, -65308(%rbp)
	movl	-65320(%rbp), %eax
	subl	$1, %eax
	movl	%eax, -65312(%rbp)
	jmp	.L31
.L35:
	movl	-65312(%rbp), %eax
	movslq	%eax, %rdx
	movl	-65308(%rbp), %eax
	cltq
	salq	$8, %rax
	addq	%rbp, %rax
	addq	%rdx, %rax
	subq	$65296, %rax
	movzbl	(%rax), %eax
	cmpb	$49, %al
	jne	.L32
	addl	$1, -65304(%rbp)
	jmp	.L33
.L32:
	movl	-65304(%rbp), %eax
	cmpl	-65300(%rbp), %eax
	jle	.L34
	movl	-65304(%rbp), %eax
	movl	%eax, -65300(%rbp)
.L34:
	movl	$0, -65304(%rbp)
.L33:
	addl	$1, -65308(%rbp)
	subl	$1, -65312(%rbp)
.L31:
	movl	-65320(%rbp), %eax
	cmpl	%eax, -65308(%rbp)
	jl	.L35
	movl	-65304(%rbp), %eax
	cmpl	-65300(%rbp), %eax
	jle	.L36
	movl	-65304(%rbp), %eax
	movl	%eax, -65300(%rbp)
.L36:
	addl	$1, -65316(%rbp)
.L30:
	movl	-65320(%rbp), %eax
	cmpl	%eax, -65316(%rbp)
	jl	.L37
	movl	$0, -65312(%rbp)
	jmp	.L38
.L45:
	movl	$0, -65304(%rbp)
	movl	$0, -65316(%rbp)
	movl	-65312(%rbp), %eax
	movl	%eax, -65308(%rbp)
	jmp	.L39
.L43:
	movl	-65308(%rbp), %eax
	movslq	%eax, %rdx
	movl	-65316(%rbp), %eax
	cltq
	salq	$8, %rax
	addq	%rbp, %rax
	addq	%rdx, %rax
	subq	$65296, %rax
	movzbl	(%rax), %eax
	cmpb	$49, %al
	jne	.L40
	addl	$1, -65304(%rbp)
	jmp	.L41
.L40:
	movl	-65304(%rbp), %eax
	cmpl	-65300(%rbp), %eax
	jle	.L42
	movl	-65304(%rbp), %eax
	movl	%eax, -65300(%rbp)
.L42:
	movl	$0, -65304(%rbp)
.L41:
	addl	$1, -65316(%rbp)
	addl	$1, -65308(%rbp)
.L39:
	movl	-65320(%rbp), %eax
	cmpl	%eax, -65308(%rbp)
	jl	.L43
	movl	-65304(%rbp), %eax
	cmpl	-65300(%rbp), %eax
	jle	.L44
	movl	-65304(%rbp), %eax
	movl	%eax, -65300(%rbp)
.L44:
	addl	$1, -65312(%rbp)
.L38:
	movl	-65320(%rbp), %eax
	cmpl	%eax, -65312(%rbp)
	jl	.L45
	movl	$1, -65316(%rbp)
	jmp	.L46
.L53:
	movl	$0, -65304(%rbp)
	movl	-65316(%rbp), %eax
	movl	%eax, -65308(%rbp)
	movl	$0, -65312(%rbp)
	jmp	.L47
.L51:
	movl	-65312(%rbp), %eax
	movslq	%eax, %rdx
	movl	-65308(%rbp), %eax
	cltq
	salq	$8, %rax
	addq	%rbp, %rax
	addq	%rdx, %rax
	subq	$65296, %rax
	movzbl	(%rax), %eax
	cmpb	$49, %al
	jne	.L48
	addl	$1, -65304(%rbp)
	jmp	.L49
.L48:
	movl	-65304(%rbp), %eax
	cmpl	-65300(%rbp), %eax
	jle	.L50
	movl	-65304(%rbp), %eax
	movl	%eax, -65300(%rbp)
.L50:
	movl	$0, -65304(%rbp)
.L49:
	addl	$1, -65308(%rbp)
	addl	$1, -65312(%rbp)
.L47:
	movl	-65320(%rbp), %eax
	cmpl	%eax, -65308(%rbp)
	jl	.L51
	movl	-65304(%rbp), %eax
	cmpl	-65300(%rbp), %eax
	jle	.L52
	movl	-65304(%rbp), %eax
	movl	%eax, -65300(%rbp)
.L52:
	addl	$1, -65316(%rbp)
.L46:
	movl	-65320(%rbp), %eax
	cmpl	%eax, -65316(%rbp)
	jl	.L53
	movl	-65300(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L54
.L58:
	nop
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L56
	call	__stack_chk_fail@PLT
.L56:
	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:
