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 d for(x=0;x<N;x++){for(y=0;y<N;y++){

int m[10][10],c,x,y,z,N=10;

int main(){d m[x][y]=x?m[x-1][y+1]+1:y?m[x][y-1]+y:1;}}
  for(;scanf("%d",&N),N;){
    printf("Case %d:\n",++c);
    d printf("%3d",(z=x+y)<N?z%2?m[x][y]:m[y][x]:N*N+1-(z%2?m[N-1-x][N-1-y]:m[N-1-y][N-1-x]));}printf("\n");}}}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	m
	.bss
	.align 32
	.type	m, @object
	.size	m, 400
m:
	.zero	400
	.globl	c
	.align 4
	.type	c, @object
	.size	c, 4
c:
	.zero	4
	.globl	x
	.align 4
	.type	x, @object
	.size	x, 4
x:
	.zero	4
	.globl	y
	.align 4
	.type	y, @object
	.size	y, 4
y:
	.zero	4
	.globl	z
	.align 4
	.type	z, @object
	.size	z, 4
z:
	.zero	4
	.globl	N
	.data
	.align 4
	.type	N, @object
	.size	N, 4
N:
	.long	10
	.section	.rodata
.LC0:
	.string	"Case %d:\n"
.LC1:
	.string	"%3d"
.LC2:
	.string	"%d"
	.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
	movl	$0, x(%rip)
	jmp	.L2
.L9:
	movl	$0, y(%rip)
	jmp	.L3
.L8:
	movl	x(%rip), %eax
	testl	%eax, %eax
	je	.L4
	movl	x(%rip), %eax
	leal	-1(%rax), %edx
	movl	y(%rip), %eax
	addl	$1, %eax
	movslq	%eax, %rcx
	movslq	%edx, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rax, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	m(%rip), %rax
	movl	(%rdx,%rax), %eax
	leal	1(%rax), %edx
	jmp	.L5
.L4:
	movl	y(%rip), %eax
	testl	%eax, %eax
	je	.L6
	movl	x(%rip), %eax
	movl	y(%rip), %edx
	subl	$1, %edx
	movslq	%edx, %rcx
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rax, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	m(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	y(%rip), %eax
	addl	%eax, %edx
	jmp	.L5
.L6:
	movl	$1, %edx
.L5:
	movl	x(%rip), %eax
	movl	y(%rip), %ecx
	movslq	%ecx, %rsi
	movslq	%eax, %rcx
	movq	%rcx, %rax
	salq	$2, %rax
	addq	%rcx, %rax
	addq	%rax, %rax
	addq	%rsi, %rax
	leaq	0(,%rax,4), %rcx
	leaq	m(%rip), %rax
	movl	%edx, (%rcx,%rax)
	movl	y(%rip), %eax
	addl	$1, %eax
	movl	%eax, y(%rip)
.L3:
	movl	y(%rip), %edx
	movl	N(%rip), %eax
	cmpl	%eax, %edx
	jl	.L8
	movl	x(%rip), %eax
	addl	$1, %eax
	movl	%eax, x(%rip)
.L2:
	movl	x(%rip), %edx
	movl	N(%rip), %eax
	cmpl	%eax, %edx
	jl	.L9
	jmp	.L10
.L21:
	movl	c(%rip), %eax
	addl	$1, %eax
	movl	%eax, c(%rip)
	movl	c(%rip), %eax
	movl	%eax, %esi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, x(%rip)
	jmp	.L11
.L20:
	movl	$0, y(%rip)
	jmp	.L12
.L19:
	movl	x(%rip), %edx
	movl	y(%rip), %eax
	addl	%edx, %eax
	movl	%eax, z(%rip)
	movl	z(%rip), %edx
	movl	N(%rip), %eax
	cmpl	%eax, %edx
	jge	.L13
	movl	z(%rip), %eax
	andl	$1, %eax
	testl	%eax, %eax
	je	.L14
	movl	x(%rip), %eax
	movl	y(%rip), %edx
	movslq	%edx, %rcx
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rax, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	m(%rip), %rax
	movl	(%rdx,%rax), %eax
	jmp	.L16
.L14:
	movl	y(%rip), %eax
	movl	x(%rip), %edx
	movslq	%edx, %rcx
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rax, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	m(%rip), %rax
	movl	(%rdx,%rax), %eax
	jmp	.L16
.L13:
	movl	N(%rip), %edx
	movl	N(%rip), %eax
	imull	%edx, %eax
	leal	1(%rax), %ecx
	movl	z(%rip), %eax
	andl	$1, %eax
	testl	%eax, %eax
	je	.L17
	movl	N(%rip), %eax
	subl	$1, %eax
	movl	x(%rip), %esi
	subl	%esi, %eax
	movl	%eax, %edx
	movl	N(%rip), %eax
	subl	$1, %eax
	movl	y(%rip), %esi
	subl	%esi, %eax
	movslq	%eax, %rsi
	movslq	%edx, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rax, %rax
	addq	%rsi, %rax
	leaq	0(,%rax,4), %rdx
	leaq	m(%rip), %rax
	movl	(%rdx,%rax), %edx
	jmp	.L18
.L17:
	movl	N(%rip), %eax
	subl	$1, %eax
	movl	y(%rip), %esi
	subl	%esi, %eax
	movl	%eax, %edx
	movl	N(%rip), %eax
	subl	$1, %eax
	movl	x(%rip), %esi
	subl	%esi, %eax
	movslq	%eax, %rsi
	movslq	%edx, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rax, %rax
	addq	%rsi, %rax
	leaq	0(,%rax,4), %rdx
	leaq	m(%rip), %rax
	movl	(%rdx,%rax), %edx
.L18:
	movl	%ecx, %eax
	subl	%edx, %eax
.L16:
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	y(%rip), %eax
	addl	$1, %eax
	movl	%eax, y(%rip)
.L12:
	movl	y(%rip), %edx
	movl	N(%rip), %eax
	cmpl	%eax, %edx
	jl	.L19
	movl	$10, %edi
	call	putchar@PLT
	movl	x(%rip), %eax
	addl	$1, %eax
	movl	%eax, x(%rip)
.L11:
	movl	x(%rip), %edx
	movl	N(%rip), %eax
	cmpl	%eax, %edx
	jl	.L20
.L10:
	leaq	N(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	N(%rip), %eax
	testl	%eax, %eax
	jne	.L21
	movl	$0, %eax
	popq	%rbp
	.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
.LC1:
	.string	"Case %d:\n"
.LC2:
	.string	"%3d"
.LC3:
	.string	"%d"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB23:
	.cfi_startproc
	endbr64
	movl	N(%rip), %edx
	pushq	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	movl	$0, x(%rip)
	pushq	%r13
	.cfi_def_cfa_offset 24
	.cfi_offset 13, -24
	pushq	%r12
	.cfi_def_cfa_offset 32
	.cfi_offset 12, -32
	pushq	%rbp
	.cfi_def_cfa_offset 40
	.cfi_offset 6, -40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	testl	%edx, %edx
	jle	.L2
	leaq	m(%rip), %r10
	movl	%edx, %ebx
	movl	%edx, %r11d
	xorl	%ecx, %ecx
	movq	%r10, %rax
	leal	-1(%rdx), %ebp
	shrl	$2, %ebx
	andl	$-4, %r11d
	movdqa	.LC0(%rip), %xmm1
	jmp	.L8
.L55:
	movl	$1, (%rax)
	cmpl	$1, %edx
	je	.L4
	movl	(%r10), %edi
	leal	1(%rdi), %esi
	movl	%esi, 4(%rax)
	cmpl	$2, %edx
	je	.L4
	movl	4+m(%rip), %edi
	leal	2(%rdi), %esi
	movl	%esi, 8(%rax)
	cmpl	$3, %edx
	je	.L4
	movl	8+m(%rip), %edi
	leal	3(%rdi), %esi
	movl	%esi, 12(%rax)
	cmpl	$4, %edx
	je	.L4
	movl	12+m(%rip), %edi
	leal	4(%rdi), %esi
	movl	%esi, 16(%rax)
	cmpl	$5, %edx
	je	.L4
	movl	16+m(%rip), %edi
	leal	5(%rdi), %esi
	movl	%esi, 20(%rax)
	cmpl	$6, %edx
	je	.L4
	movl	20+m(%rip), %edi
	leal	6(%rdi), %esi
	movl	%esi, 24(%rax)
	cmpl	$7, %edx
	je	.L4
	movl	24+m(%rip), %edi
	leal	7(%rdi), %esi
	movl	%esi, 28(%rax)
	cmpl	$8, %edx
	je	.L4
	movl	28+m(%rip), %edi
	leal	8(%rdi), %esi
	movl	%esi, 32(%rax)
	cmpl	$9, %edx
	je	.L4
	movl	32+m(%rip), %edi
	leal	9(%rdi), %esi
	movl	%esi, 36(%rax)
.L4:
	addl	$1, %ecx
	addq	$40, %rax
	cmpl	%ecx, %edx
	je	.L54
.L8:
	testl	%ecx, %ecx
	je	.L55
	cmpl	$2, %ebp
	jbe	.L20
	movdqu	-36(%rax), %xmm0
	paddd	%xmm1, %xmm0
	movups	%xmm0, (%rax)
	cmpl	$1, %ebx
	jbe	.L6
	movdqu	-20(%rax), %xmm0
	paddd	%xmm1, %xmm0
	movups	%xmm0, 16(%rax)
.L6:
	movl	%r11d, %esi
	cmpl	%r11d, %edx
	je	.L4
.L5:
	leal	-1(%rcx), %r8d
	leal	1(%rsi), %r13d
	movslq	%ecx, %rdi
	movslq	%esi, %r9
	movslq	%r8d, %r8
	movslq	%r13d, %r12
	leaq	(%rdi,%rdi,4), %rdi
	leaq	(%r8,%r8,4), %r8
	addq	%rdi, %rdi
	addq	%r8, %r8
	addq	%rdi, %r9
	leaq	(%r8,%r12), %r14
	movl	(%r10,%r14,4), %r14d
	addl	$1, %r14d
	movl	%r14d, (%r10,%r9,4)
	cmpl	%r13d, %edx
	jle	.L4
	leal	2(%rsi), %r14d
	addq	%rdi, %r12
	movslq	%r14d, %r13
	leaq	(%r8,%r13), %r9
	movl	(%r10,%r9,4), %r9d
	addl	$1, %r9d
	movl	%r9d, (%r10,%r12,4)
	cmpl	%r14d, %edx
	jle	.L4
	addl	$3, %esi
	addq	%r13, %rdi
	addl	$1, %ecx
	addq	$40, %rax
	movslq	%esi, %rsi
	addq	%rsi, %r8
	movl	(%r10,%r8,4), %esi
	addl	$1, %esi
	movl	%esi, (%r10,%rdi,4)
	cmpl	%ecx, %edx
	jne	.L8
.L54:
	movl	%edx, y(%rip)
	movl	%edx, x(%rip)
.L2:
	leaq	N(%rip), %r13
	leaq	.LC3(%rip), %r12
	leaq	.LC1(%rip), %r14
	leaq	m(%rip), %rbp
	leaq	.LC2(%rip), %rbx
	.p2align 4,,10
	.p2align 3
.L9:
	movq	%r13, %rsi
	movq	%r12, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	N(%rip), %eax
	testl	%eax, %eax
	je	.L56
	movl	c(%rip), %eax
	movq	%r14, %rsi
	movl	$1, %edi
	leal	1(%rax), %edx
	xorl	%eax, %eax
	movl	%edx, c(%rip)
	call	__printf_chk@PLT
	movl	N(%rip), %eax
	xorl	%esi, %esi
	movl	$0, x(%rip)
	testl	%eax, %eax
	jle	.L9
	.p2align 4,,10
	.p2align 3
.L10:
	movl	$0, y(%rip)
	testl	%eax, %eax
	jle	.L11
	xorl	%ecx, %ecx
	jmp	.L17
	.p2align 4,,10
	.p2align 3
.L57:
	testl	%r8d, %r8d
	je	.L13
	movslq	%esi, %rsi
	movslq	%ecx, %rcx
	leaq	(%rsi,%rsi,4), %rax
	leaq	(%rcx,%rax,2), %rax
	movl	0(%rbp,%rax,4), %edx
.L14:
	movq	%rbx, %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movl	y(%rip), %eax
	leal	1(%rax), %ecx
	movl	N(%rip), %eax
	movl	%ecx, y(%rip)
	cmpl	%eax, %ecx
	jge	.L11
	movl	x(%rip), %esi
.L17:
	leal	(%rcx,%rsi), %edx
	movl	%edx, %r8d
	movl	%edx, z(%rip)
	andl	$1, %r8d
	cmpl	%eax, %edx
	jl	.L57
	movl	%eax, %edx
	imull	%eax, %edx
	subl	$1, %eax
	movl	%eax, %edi
	subl	%esi, %eax
	subl	%ecx, %edi
	addl	$1, %edx
	testl	%r8d, %r8d
	je	.L15
	cltq
	movslq	%edi, %rdi
	leaq	(%rax,%rax,4), %rax
	leaq	(%rdi,%rax,2), %rax
	movl	0(%rbp,%rax,4), %eax
	subl	%eax, %edx
	jmp	.L14
	.p2align 4,,10
	.p2align 3
.L15:
	movslq	%edi, %rdi
	cltq
	leaq	(%rdi,%rdi,4), %rcx
	leaq	(%rax,%rcx,2), %rax
	movl	0(%rbp,%rax,4), %eax
	subl	%eax, %edx
	jmp	.L14
	.p2align 4,,10
	.p2align 3
.L13:
	movslq	%ecx, %rcx
	movslq	%esi, %rsi
	leaq	(%rcx,%rcx,4), %rax
	leaq	(%rsi,%rax,2), %rax
	movl	0(%rbp,%rax,4), %edx
	jmp	.L14
	.p2align 4,,10
	.p2align 3
.L11:
	movl	$10, %edi
	call	putchar@PLT
	movl	x(%rip), %eax
	leal	1(%rax), %esi
	movl	N(%rip), %eax
	movl	%esi, x(%rip)
	cmpl	%eax, %esi
	jl	.L10
	jmp	.L9
.L56:
	popq	%rbx
	.cfi_remember_state
	.cfi_def_cfa_offset 40
	xorl	%eax, %eax
	popq	%rbp
	.cfi_def_cfa_offset 32
	popq	%r12
	.cfi_def_cfa_offset 24
	popq	%r13
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	ret
.L20:
	.cfi_restore_state
	xorl	%esi, %esi
	jmp	.L5
	.cfi_endproc
.LFE23:
	.size	main, .-main
	.globl	N
	.data
	.align 4
	.type	N, @object
	.size	N, 4
N:
	.long	10
	.globl	z
	.bss
	.align 4
	.type	z, @object
	.size	z, 4
z:
	.zero	4
	.globl	y
	.align 4
	.type	y, @object
	.size	y, 4
y:
	.zero	4
	.globl	x
	.align 4
	.type	x, @object
	.size	x, 4
x:
	.zero	4
	.globl	c
	.align 4
	.type	c, @object
	.size	c, 4
c:
	.zero	4
	.globl	m
	.align 32
	.type	m, @object
	.size	m, 400
m:
	.zero	400
	.section	.rodata.cst16,"aM",@progbits,16
	.align 16
.LC0:
	.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
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC1:
	.string	"Case %d:\n"
.LC2:
	.string	"%3d"
.LC3:
	.string	"%d"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB23:
	.cfi_startproc
	endbr64
	movl	N(%rip), %edx
	pushq	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	movl	$0, x(%rip)
	pushq	%r13
	.cfi_def_cfa_offset 24
	.cfi_offset 13, -24
	pushq	%r12
	.cfi_def_cfa_offset 32
	.cfi_offset 12, -32
	pushq	%rbp
	.cfi_def_cfa_offset 40
	.cfi_offset 6, -40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	testl	%edx, %edx
	jle	.L2
	leaq	m(%rip), %r10
	movl	%edx, %ebx
	movl	%edx, %r11d
	xorl	%ecx, %ecx
	movq	%r10, %rax
	leal	-1(%rdx), %ebp
	shrl	$2, %ebx
	andl	$-4, %r11d
	movdqa	.LC0(%rip), %xmm1
	jmp	.L8
.L55:
	movl	$1, (%rax)
	cmpl	$1, %edx
	je	.L4
	movl	(%r10), %edi
	leal	1(%rdi), %esi
	movl	%esi, 4(%rax)
	cmpl	$2, %edx
	je	.L4
	movl	4+m(%rip), %edi
	leal	2(%rdi), %esi
	movl	%esi, 8(%rax)
	cmpl	$3, %edx
	je	.L4
	movl	8+m(%rip), %edi
	leal	3(%rdi), %esi
	movl	%esi, 12(%rax)
	cmpl	$4, %edx
	je	.L4
	movl	12+m(%rip), %edi
	leal	4(%rdi), %esi
	movl	%esi, 16(%rax)
	cmpl	$5, %edx
	je	.L4
	movl	16+m(%rip), %edi
	leal	5(%rdi), %esi
	movl	%esi, 20(%rax)
	cmpl	$6, %edx
	je	.L4
	movl	20+m(%rip), %edi
	leal	6(%rdi), %esi
	movl	%esi, 24(%rax)
	cmpl	$7, %edx
	je	.L4
	movl	24+m(%rip), %edi
	leal	7(%rdi), %esi
	movl	%esi, 28(%rax)
	cmpl	$8, %edx
	je	.L4
	movl	28+m(%rip), %edi
	leal	8(%rdi), %esi
	movl	%esi, 32(%rax)
	cmpl	$9, %edx
	je	.L4
	movl	32+m(%rip), %edi
	leal	9(%rdi), %esi
	movl	%esi, 36(%rax)
.L4:
	addl	$1, %ecx
	addq	$40, %rax
	cmpl	%ecx, %edx
	je	.L54
.L8:
	testl	%ecx, %ecx
	je	.L55
	cmpl	$2, %ebp
	jbe	.L20
	movdqu	-36(%rax), %xmm0
	paddd	%xmm1, %xmm0
	movups	%xmm0, (%rax)
	cmpl	$1, %ebx
	jbe	.L6
	movdqu	-20(%rax), %xmm0
	paddd	%xmm1, %xmm0
	movups	%xmm0, 16(%rax)
.L6:
	movl	%r11d, %esi
	cmpl	%r11d, %edx
	je	.L4
.L5:
	leal	-1(%rcx), %r8d
	leal	1(%rsi), %r13d
	movslq	%ecx, %rdi
	movslq	%esi, %r9
	movslq	%r8d, %r8
	movslq	%r13d, %r12
	leaq	(%rdi,%rdi,4), %rdi
	leaq	(%r8,%r8,4), %r8
	addq	%rdi, %rdi
	addq	%r8, %r8
	addq	%rdi, %r9
	leaq	(%r8,%r12), %r14
	movl	(%r10,%r14,4), %r14d
	addl	$1, %r14d
	movl	%r14d, (%r10,%r9,4)
	cmpl	%r13d, %edx
	jle	.L4
	leal	2(%rsi), %r14d
	addq	%rdi, %r12
	movslq	%r14d, %r13
	leaq	(%r8,%r13), %r9
	movl	(%r10,%r9,4), %r9d
	addl	$1, %r9d
	movl	%r9d, (%r10,%r12,4)
	cmpl	%r14d, %edx
	jle	.L4
	addl	$3, %esi
	addq	%r13, %rdi
	addl	$1, %ecx
	addq	$40, %rax
	movslq	%esi, %rsi
	addq	%rsi, %r8
	movl	(%r10,%r8,4), %esi
	addl	$1, %esi
	movl	%esi, (%r10,%rdi,4)
	cmpl	%ecx, %edx
	jne	.L8
.L54:
	movl	%edx, y(%rip)
	movl	%edx, x(%rip)
.L2:
	leaq	N(%rip), %r13
	leaq	.LC3(%rip), %r12
	leaq	.LC1(%rip), %r14
	leaq	m(%rip), %rbp
	leaq	.LC2(%rip), %rbx
	.p2align 4,,10
	.p2align 3
.L9:
	movq	%r13, %rsi
	movq	%r12, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	N(%rip), %eax
	testl	%eax, %eax
	je	.L56
	movl	c(%rip), %eax
	movq	%r14, %rsi
	movl	$1, %edi
	leal	1(%rax), %edx
	xorl	%eax, %eax
	movl	%edx, c(%rip)
	call	__printf_chk@PLT
	movl	N(%rip), %eax
	xorl	%esi, %esi
	movl	$0, x(%rip)
	testl	%eax, %eax
	jle	.L9
	.p2align 4,,10
	.p2align 3
.L10:
	movl	$0, y(%rip)
	testl	%eax, %eax
	jle	.L11
	xorl	%ecx, %ecx
	jmp	.L17
	.p2align 4,,10
	.p2align 3
.L57:
	testl	%r8d, %r8d
	je	.L13
	movslq	%esi, %rsi
	movslq	%ecx, %rcx
	leaq	(%rsi,%rsi,4), %rax
	leaq	(%rcx,%rax,2), %rax
	movl	0(%rbp,%rax,4), %edx
.L14:
	movq	%rbx, %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movl	y(%rip), %eax
	leal	1(%rax), %ecx
	movl	N(%rip), %eax
	movl	%ecx, y(%rip)
	cmpl	%eax, %ecx
	jge	.L11
	movl	x(%rip), %esi
.L17:
	leal	(%rcx,%rsi), %edx
	movl	%edx, %r8d
	movl	%edx, z(%rip)
	andl	$1, %r8d
	cmpl	%eax, %edx
	jl	.L57
	movl	%eax, %edx
	imull	%eax, %edx
	subl	$1, %eax
	movl	%eax, %edi
	subl	%esi, %eax
	subl	%ecx, %edi
	addl	$1, %edx
	testl	%r8d, %r8d
	je	.L15
	cltq
	movslq	%edi, %rdi
	leaq	(%rax,%rax,4), %rax
	leaq	(%rdi,%rax,2), %rax
	movl	0(%rbp,%rax,4), %eax
	subl	%eax, %edx
	jmp	.L14
	.p2align 4,,10
	.p2align 3
.L15:
	movslq	%edi, %rdi
	cltq
	leaq	(%rdi,%rdi,4), %rcx
	leaq	(%rax,%rcx,2), %rax
	movl	0(%rbp,%rax,4), %eax
	subl	%eax, %edx
	jmp	.L14
	.p2align 4,,10
	.p2align 3
.L13:
	movslq	%ecx, %rcx
	movslq	%esi, %rsi
	leaq	(%rcx,%rcx,4), %rax
	leaq	(%rsi,%rax,2), %rax
	movl	0(%rbp,%rax,4), %edx
	jmp	.L14
	.p2align 4,,10
	.p2align 3
.L11:
	movl	$10, %edi
	call	putchar@PLT
	movl	x(%rip), %eax
	leal	1(%rax), %esi
	movl	N(%rip), %eax
	movl	%esi, x(%rip)
	cmpl	%eax, %esi
	jl	.L10
	jmp	.L9
.L56:
	popq	%rbx
	.cfi_remember_state
	.cfi_def_cfa_offset 40
	xorl	%eax, %eax
	popq	%rbp
	.cfi_def_cfa_offset 32
	popq	%r12
	.cfi_def_cfa_offset 24
	popq	%r13
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	ret
.L20:
	.cfi_restore_state
	xorl	%esi, %esi
	jmp	.L5
	.cfi_endproc
.LFE23:
	.size	main, .-main
	.globl	N
	.data
	.align 4
	.type	N, @object
	.size	N, 4
N:
	.long	10
	.globl	z
	.bss
	.align 4
	.type	z, @object
	.size	z, 4
z:
	.zero	4
	.globl	y
	.align 4
	.type	y, @object
	.size	y, 4
y:
	.zero	4
	.globl	x
	.align 4
	.type	x, @object
	.size	x, 4
x:
	.zero	4
	.globl	c
	.align 4
	.type	c, @object
	.size	c, 4
c:
	.zero	4
	.globl	m
	.align 32
	.type	m, @object
	.size	m, 400
m:
	.zero	400
	.section	.rodata.cst16,"aM",@progbits,16
	.align 16
.LC0:
	.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>
#define d for(x=0;x<N;x++){for(y=0;y<N;y++){

int m[10][10],c,x,y,z,N=10;

int main(){d m[x][y]=x?m[x-1][y+1]+1:y?m[x][y-1]+y:1;}}
  for(;scanf("%d",&N),N;){
    printf("Case %d:\n",++c);
    d printf("%3d",(z=x+y)<N?z%2?m[x][y]:m[y][x]:N*N+1-(z%2?m[N-1-x][N-1-y]:m[N-1-y][N-1-x]));}printf("\n");}}}
3
7
0
 3
3
0
 3
0
0
 3
1
0
 3
2
0
 3
-1
0
 3
5
0
 3
8
0
 3
6
0
 3
9
0

Case 1:
  1  2  6
  3  5  7
  4  8  9
Case 2:
  1  2  6  7 15 16 28
  3  5  8 14 17 27 29
  4  9 13 18 26 30 39
 10 12 19 25 31 38 40
 11 20 24 32 37 41 46
 21 23 33 36 42 45 47
 22 34 35 43 44 48 49
 Case 1:
  1  2  6
  3  5  7
  4  8  9
Case 2:
  1  2  6
  3  5  7
  4  8  9
 Case 1:
  1  2  6
  3  5  7
  4  8  9
 Case 1:
  1  2  6
  3  5  7
  4  8  9
Case 2:
  1
 Case 1:
  1  2  6
  3  5  7
  4  8  9
Case 2:
  1  2
  3  4
 Case 1:
  1  2  6
  3  5  7
  4  8  9
Case 2:
 Case 1:
  1  2  6
  3  5  7
  4  8  9
Case 2:
  1  2  6  7 15
  3  5  8 14 16
  4  9 13 17 22
 10 12 18 21 23
 11 19 20 24 25
 Case 1:
  1  2  6
  3  5  7
  4  8  9
Case 2:
  1  2  6  7 15 16 28 29
  3  5  8 14 17 27 30 43
  4  9 13 18 26 31 42 44
 10 12 19 25 32 41 45 54
 11 20 24 33 40 46 53 55
 21 23 34 39 47 52 56 61
 22 35 38 48 51 57 60 62
 36 37 49 50 58 59 63 64
 Case 1:
  1  2  6
  3  5  7
  4  8  9
Case 2:
  1  2  6  7 15 16
  3  5  8 14 17 26
  4  9 13 18 25 27
 10 12 19 24 28 33
 11 20 23 29 32 34
 21 22 30 31 35 36
 Case 1:
  1  2  6
  3  5  7
  4  8  9
Case 2:
  1  2  6  7 15 16 28 29 45
  3  5  8 14 17 27 30 44 46
  4  9 13 18 26 31 43 47 60
 10 12 19 25 32 42 48 59 61
 11 20 24 33 41 49 58 62 71
 21 23 34 40 50 57 63 70 72
 22 35 39 51 56 64 69 73 78
 36 38 52 55 65 68 74 77 79
 37 53 54 66 67 75 76 80 81

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 d for(x=0;x<N;x++){for(y=0;y<N;y++){

int m[10][10],c,x,y,z,N=10;

int main(){d m[x][y]=x?m[x-1][y+1]+1:y?m[x][y-1]+y:1;}}
  for(;scanf("%d",&N),N;){
    printf("Case %d:\n",++c);
    d printf("%3d",(z=x+y)<N?z%2?m[x][y]:m[y][x]:N*N+1-(z%2?m[N-1-x][N-1-y]:m[N-1-y][N-1-x]));}printf("\n");}}}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	m
	.bss
	.align 32
	.type	m, @object
	.size	m, 400
m:
	.zero	400
	.globl	c
	.align 4
	.type	c, @object
	.size	c, 4
c:
	.zero	4
	.globl	x
	.align 4
	.type	x, @object
	.size	x, 4
x:
	.zero	4
	.globl	y
	.align 4
	.type	y, @object
	.size	y, 4
y:
	.zero	4
	.globl	z
	.align 4
	.type	z, @object
	.size	z, 4
z:
	.zero	4
	.globl	N
	.data
	.align 4
	.type	N, @object
	.size	N, 4
N:
	.long	10
	.section	.rodata
.LC0:
	.string	"Case %d:\n"
.LC1:
	.string	"%3d"
.LC2:
	.string	"%d"
	.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
	movl	$0, x(%rip)
	jmp	.L2
.L9:
	movl	$0, y(%rip)
	jmp	.L3
.L8:
	movl	x(%rip), %eax
	testl	%eax, %eax
	je	.L4
	movl	x(%rip), %eax
	leal	-1(%rax), %edx
	movl	y(%rip), %eax
	addl	$1, %eax
	movslq	%eax, %rcx
	movslq	%edx, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rax, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	m(%rip), %rax
	movl	(%rdx,%rax), %eax
	leal	1(%rax), %edx
	jmp	.L5
.L4:
	movl	y(%rip), %eax
	testl	%eax, %eax
	je	.L6
	movl	x(%rip), %eax
	movl	y(%rip), %edx
	subl	$1, %edx
	movslq	%edx, %rcx
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rax, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	m(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	y(%rip), %eax
	addl	%eax, %edx
	jmp	.L5
.L6:
	movl	$1, %edx
.L5:
	movl	x(%rip), %eax
	movl	y(%rip), %ecx
	movslq	%ecx, %rsi
	movslq	%eax, %rcx
	movq	%rcx, %rax
	salq	$2, %rax
	addq	%rcx, %rax
	addq	%rax, %rax
	addq	%rsi, %rax
	leaq	0(,%rax,4), %rcx
	leaq	m(%rip), %rax
	movl	%edx, (%rcx,%rax)
	movl	y(%rip), %eax
	addl	$1, %eax
	movl	%eax, y(%rip)
.L3:
	movl	y(%rip), %edx
	movl	N(%rip), %eax
	cmpl	%eax, %edx
	jl	.L8
	movl	x(%rip), %eax
	addl	$1, %eax
	movl	%eax, x(%rip)
.L2:
	movl	x(%rip), %edx
	movl	N(%rip), %eax
	cmpl	%eax, %edx
	jl	.L9
	jmp	.L10
.L21:
	movl	c(%rip), %eax
	addl	$1, %eax
	movl	%eax, c(%rip)
	movl	c(%rip), %eax
	movl	%eax, %esi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, x(%rip)
	jmp	.L11
.L20:
	movl	$0, y(%rip)
	jmp	.L12
.L19:
	movl	x(%rip), %edx
	movl	y(%rip), %eax
	addl	%edx, %eax
	movl	%eax, z(%rip)
	movl	z(%rip), %edx
	movl	N(%rip), %eax
	cmpl	%eax, %edx
	jge	.L13
	movl	z(%rip), %eax
	andl	$1, %eax
	testl	%eax, %eax
	je	.L14
	movl	x(%rip), %eax
	movl	y(%rip), %edx
	movslq	%edx, %rcx
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rax, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	m(%rip), %rax
	movl	(%rdx,%rax), %eax
	jmp	.L16
.L14:
	movl	y(%rip), %eax
	movl	x(%rip), %edx
	movslq	%edx, %rcx
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rax, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	m(%rip), %rax
	movl	(%rdx,%rax), %eax
	jmp	.L16
.L13:
	movl	N(%rip), %edx
	movl	N(%rip), %eax
	imull	%edx, %eax
	leal	1(%rax), %ecx
	movl	z(%rip), %eax
	andl	$1, %eax
	testl	%eax, %eax
	je	.L17
	movl	N(%rip), %eax
	subl	$1, %eax
	movl	x(%rip), %esi
	subl	%esi, %eax
	movl	%eax, %edx
	movl	N(%rip), %eax
	subl	$1, %eax
	movl	y(%rip), %esi
	subl	%esi, %eax
	movslq	%eax, %rsi
	movslq	%edx, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rax, %rax
	addq	%rsi, %rax
	leaq	0(,%rax,4), %rdx
	leaq	m(%rip), %rax
	movl	(%rdx,%rax), %edx
	jmp	.L18
.L17:
	movl	N(%rip), %eax
	subl	$1, %eax
	movl	y(%rip), %esi
	subl	%esi, %eax
	movl	%eax, %edx
	movl	N(%rip), %eax
	subl	$1, %eax
	movl	x(%rip), %esi
	subl	%esi, %eax
	movslq	%eax, %rsi
	movslq	%edx, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rax, %rax
	addq	%rsi, %rax
	leaq	0(,%rax,4), %rdx
	leaq	m(%rip), %rax
	movl	(%rdx,%rax), %edx
.L18:
	movl	%ecx, %eax
	subl	%edx, %eax
.L16:
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	y(%rip), %eax
	addl	$1, %eax
	movl	%eax, y(%rip)
.L12:
	movl	y(%rip), %edx
	movl	N(%rip), %eax
	cmpl	%eax, %edx
	jl	.L19
	movl	$10, %edi
	call	putchar@PLT
	movl	x(%rip), %eax
	addl	$1, %eax
	movl	%eax, x(%rip)
.L11:
	movl	x(%rip), %edx
	movl	N(%rip), %eax
	cmpl	%eax, %edx
	jl	.L20
.L10:
	leaq	N(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	N(%rip), %eax
	testl	%eax, %eax
	jne	.L21
	movl	$0, %eax
	popq	%rbp
	.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
	.globl	m
	.bss
	.align 32
	.type	m, @object
	.size	m, 400
m:
	.zero	400
	.globl	c
	.align 4
	.type	c, @object
	.size	c, 4
c:
	.zero	4
	.globl	x
	.align 4
	.type	x, @object
	.size	x, 4
x:
	.zero	4
	.globl	y
	.align 4
	.type	y, @object
	.size	y, 4
y:
	.zero	4
	.globl	z
	.align 4
	.type	z, @object
	.size	z, 4
z:
	.zero	4
	.globl	N
	.data
	.align 4
	.type	N, @object
	.size	N, 4
N:
	.long	10
	.section	.rodata
.LC0:
	.string	"Case %d:\n"
.LC1:
	.string	"%3d"
.LC2:
	.string	"%d"
	.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
	movl	$0, x(%rip)
	jmp	.L2
.L9:
	movl	$0, y(%rip)
	jmp	.L3
.L8:
	movl	x(%rip), %eax
	testl	%eax, %eax
	je	.L4
	movl	x(%rip), %eax
	leal	-1(%rax), %edx
	movl	y(%rip), %eax
	addl	$1, %eax
	movslq	%eax, %rcx
	movslq	%edx, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rax, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	m(%rip), %rax
	movl	(%rdx,%rax), %eax
	leal	1(%rax), %edx
	jmp	.L5
.L4:
	movl	y(%rip), %eax
	testl	%eax, %eax
	je	.L6
	movl	x(%rip), %eax
	movl	y(%rip), %edx
	subl	$1, %edx
	movslq	%edx, %rcx
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rax, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	m(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	y(%rip), %eax
	addl	%eax, %edx
	jmp	.L5
.L6:
	movl	$1, %edx
.L5:
	movl	x(%rip), %eax
	movl	y(%rip), %ecx
	movslq	%ecx, %rsi
	movslq	%eax, %rcx
	movq	%rcx, %rax
	salq	$2, %rax
	addq	%rcx, %rax
	addq	%rax, %rax
	addq	%rsi, %rax
	leaq	0(,%rax,4), %rcx
	leaq	m(%rip), %rax
	movl	%edx, (%rcx,%rax)
	movl	y(%rip), %eax
	addl	$1, %eax
	movl	%eax, y(%rip)
.L3:
	movl	y(%rip), %edx
	movl	N(%rip), %eax
	cmpl	%eax, %edx
	jl	.L8
	movl	x(%rip), %eax
	addl	$1, %eax
	movl	%eax, x(%rip)
.L2:
	movl	x(%rip), %edx
	movl	N(%rip), %eax
	cmpl	%eax, %edx
	jl	.L9
	jmp	.L10
.L21:
	movl	c(%rip), %eax
	addl	$1, %eax
	movl	%eax, c(%rip)
	movl	c(%rip), %eax
	movl	%eax, %esi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, x(%rip)
	jmp	.L11
.L20:
	movl	$0, y(%rip)
	jmp	.L12
.L19:
	movl	x(%rip), %edx
	movl	y(%rip), %eax
	addl	%edx, %eax
	movl	%eax, z(%rip)
	movl	z(%rip), %edx
	movl	N(%rip), %eax
	cmpl	%eax, %edx
	jge	.L13
	movl	z(%rip), %eax
	andl	$1, %eax
	testl	%eax, %eax
	je	.L14
	movl	x(%rip), %eax
	movl	y(%rip), %edx
	movslq	%edx, %rcx
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rax, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	m(%rip), %rax
	movl	(%rdx,%rax), %eax
	jmp	.L16
.L14:
	movl	y(%rip), %eax
	movl	x(%rip), %edx
	movslq	%edx, %rcx
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rax, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	m(%rip), %rax
	movl	(%rdx,%rax), %eax
	jmp	.L16
.L13:
	movl	N(%rip), %edx
	movl	N(%rip), %eax
	imull	%edx, %eax
	leal	1(%rax), %ecx
	movl	z(%rip), %eax
	andl	$1, %eax
	testl	%eax, %eax
	je	.L17
	movl	N(%rip), %eax
	subl	$1, %eax
	movl	x(%rip), %esi
	subl	%esi, %eax
	movl	%eax, %edx
	movl	N(%rip), %eax
	subl	$1, %eax
	movl	y(%rip), %esi
	subl	%esi, %eax
	movslq	%eax, %rsi
	movslq	%edx, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rax, %rax
	addq	%rsi, %rax
	leaq	0(,%rax,4), %rdx
	leaq	m(%rip), %rax
	movl	(%rdx,%rax), %edx
	jmp	.L18
.L17:
	movl	N(%rip), %eax
	subl	$1, %eax
	movl	y(%rip), %esi
	subl	%esi, %eax
	movl	%eax, %edx
	movl	N(%rip), %eax
	subl	$1, %eax
	movl	x(%rip), %esi
	subl	%esi, %eax
	movslq	%eax, %rsi
	movslq	%edx, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rax, %rax
	addq	%rsi, %rax
	leaq	0(,%rax,4), %rdx
	leaq	m(%rip), %rax
	movl	(%rdx,%rax), %edx
.L18:
	movl	%ecx, %eax
	subl	%edx, %eax
.L16:
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	y(%rip), %eax
	addl	$1, %eax
	movl	%eax, y(%rip)
.L12:
	movl	y(%rip), %edx
	movl	N(%rip), %eax
	cmpl	%eax, %edx
	jl	.L19
	movl	$10, %edi
	call	putchar@PLT
	movl	x(%rip), %eax
	addl	$1, %eax
	movl	%eax, x(%rip)
.L11:
	movl	x(%rip), %edx
	movl	N(%rip), %eax
	cmpl	%eax, %edx
	jl	.L20
.L10:
	leaq	N(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	N(%rip), %eax
	testl	%eax, %eax
	jne	.L21
	movl	$0, %eax
	popq	%rbp
	.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:
