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

```c
#define d for(x=0;x<N;x++){for(y=0;y<N;y++
c,m[10][10],x,N;main(y){for(;scanf("%d",&N),N;){d)m[x][y]=(x+y)*(x+y+1)/2+1+(x+y&1?x:y);}printf("Case %d:\n",++c);d)printf("%3d",x+y<N?m[x][y]:N*N+1-m[N-1-x][N-1-y]);puts("");}}exit(0);}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	c
	.bss
	.align 4
	.type	c, @object
	.size	c, 4
c:
	.zero	4
	.globl	m
	.align 32
	.type	m, @object
	.size	m, 400
m:
	.zero	400
	.globl	x
	.align 4
	.type	x, @object
	.size	x, 4
x:
	.zero	4
	.globl	N
	.align 4
	.type	N, @object
	.size	N, 4
N:
	.zero	4
	.section	.rodata
.LC0:
	.string	"Case %d:\n"
.LC1:
	.string	"%3d"
.LC2:
	.string	""
.LC3:
	.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
	subq	$16, %rsp
	movl	%edi, -4(%rbp)
	jmp	.L2
.L15:
	movl	$0, x(%rip)
	jmp	.L3
.L8:
	movl	$0, -4(%rbp)
	jmp	.L4
.L7:
	movl	x(%rip), %edx
	movl	-4(%rbp), %eax
	addl	%eax, %edx
	movl	x(%rip), %ecx
	movl	-4(%rbp), %eax
	addl	%ecx, %eax
	addl	$1, %eax
	imull	%edx, %eax
	movl	%eax, %edx
	shrl	$31, %edx
	addl	%edx, %eax
	sarl	%eax
	leal	1(%rax), %ecx
	movl	x(%rip), %edx
	movl	-4(%rbp), %eax
	addl	%edx, %eax
	andl	$1, %eax
	testl	%eax, %eax
	je	.L5
	movl	x(%rip), %eax
	jmp	.L6
.L5:
	movl	-4(%rbp), %eax
.L6:
	movl	x(%rip), %edx
	addl	%eax, %ecx
	movl	-4(%rbp), %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	%ecx, (%rdx,%rax)
	addl	$1, -4(%rbp)
.L4:
	movl	N(%rip), %eax
	cmpl	%eax, -4(%rbp)
	jl	.L7
	movl	x(%rip), %eax
	addl	$1, %eax
	movl	%eax, x(%rip)
.L3:
	movl	x(%rip), %edx
	movl	N(%rip), %eax
	cmpl	%eax, %edx
	jl	.L8
	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	.L9
.L14:
	movl	$0, -4(%rbp)
	jmp	.L10
.L13:
	movl	x(%rip), %edx
	movl	-4(%rbp), %eax
	addl	%eax, %edx
	movl	N(%rip), %eax
	cmpl	%eax, %edx
	jge	.L11
	movl	x(%rip), %eax
	movl	-4(%rbp), %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	.L12
.L11:
	movl	N(%rip), %edx
	movl	N(%rip), %eax
	imull	%edx, %eax
	leal	1(%rax), %ecx
	movl	N(%rip), %eax
	subl	$1, %eax
	movl	x(%rip), %esi
	subl	%esi, %eax
	movl	%eax, %edx
	movl	N(%rip), %eax
	subl	$1, %eax
	subl	-4(%rbp), %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
	movl	%ecx, %eax
	subl	%edx, %eax
.L12:
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	addl	$1, -4(%rbp)
.L10:
	movl	N(%rip), %eax
	cmpl	%eax, -4(%rbp)
	jl	.L13
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	movl	x(%rip), %eax
	addl	$1, %eax
	movl	%eax, x(%rip)
.L9:
	movl	x(%rip), %edx
	movl	N(%rip), %eax
	cmpl	%eax, %edx
	jl	.L14
.L2:
	leaq	N(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	scanf@PLT
	movl	N(%rip), %eax
	testl	%eax, %eax
	jne	.L15
	movl	$0, %edi
	call	exit@PLT
	.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
.LC5:
	.string	"Case %d:\n"
.LC6:
	.string	"%3d"
.LC7:
	.string	""
.LC8:
	.string	"%d"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB0:
	.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
	leaq	N(%rip), %r14
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	leaq	.LC8(%rip), %r13
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$8, %rsp
	.cfi_def_cfa_offset 64
	.p2align 4,,10
	.p2align 3
.L2:
	movq	%r13, %rdi
	movq	%r14, %rsi
	xorl	%eax, %eax
	call	scanf@PLT
	movl	N(%rip), %edi
	testl	%edi, %edi
	je	.L30
	movl	$0, x(%rip)
	jle	.L3
	leaq	m(%rip), %rbx
	movl	%edi, %r11d
	movl	%edi, %r9d
	xorl	%eax, %eax
	movq	%rbx, %r8
	leal	-1(%rdi), %r10d
	shrl	$2, %r11d
	andl	$-4, %r9d
	movdqa	.LC3(%rip), %xmm4
	movdqa	.LC4(%rip), %xmm5
	pxor	%xmm3, %xmm3
	.p2align 4,,10
	.p2align 3
.L10:
	cmpl	$2, %r10d
	jbe	.L18
	movd	%eax, %xmm7
	movdqa	.LC0(%rip), %xmm1
	movdqa	.LC1(%rip), %xmm6
	pshufd	$0, %xmm7, %xmm2
	paddd	%xmm2, %xmm1
	paddd	%xmm2, %xmm6
	movdqa	%xmm1, %xmm7
	movdqa	%xmm6, %xmm0
	psrlq	$32, %xmm7
	psrlq	$32, %xmm6
	pmuludq	%xmm1, %xmm0
	pmuludq	%xmm7, %xmm6
	pand	.LC2(%rip), %xmm1
	pcmpeqd	%xmm3, %xmm1
	pshufd	$8, %xmm6, %xmm6
	pshufd	$8, %xmm0, %xmm0
	punpckldq	%xmm6, %xmm0
	movdqa	.LC0(%rip), %xmm6
	pand	%xmm1, %xmm6
	pandn	%xmm2, %xmm1
	por	%xmm6, %xmm1
	movdqa	%xmm3, %xmm6
	pcmpgtd	%xmm0, %xmm6
	psubd	%xmm6, %xmm0
	psrad	$1, %xmm0
	paddd	.LC2(%rip), %xmm0
	paddd	%xmm1, %xmm0
	movups	%xmm0, (%r8)
	cmpl	$1, %r11d
	jbe	.L5
	movdqa	%xmm2, %xmm1
	movdqa	%xmm2, %xmm6
	paddd	%xmm4, %xmm1
	paddd	%xmm5, %xmm6
	movdqa	%xmm1, %xmm7
	movdqa	%xmm6, %xmm0
	psrlq	$32, %xmm7
	psrlq	$32, %xmm6
	pmuludq	%xmm1, %xmm0
	pmuludq	%xmm7, %xmm6
	pand	.LC2(%rip), %xmm1
	pcmpeqd	%xmm3, %xmm1
	pshufd	$8, %xmm6, %xmm6
	pshufd	$8, %xmm0, %xmm0
	punpckldq	%xmm6, %xmm0
	movdqa	%xmm4, %xmm6
	pand	%xmm1, %xmm6
	pandn	%xmm2, %xmm1
	movdqa	%xmm3, %xmm2
	pcmpgtd	%xmm0, %xmm2
	por	%xmm6, %xmm1
	psubd	%xmm2, %xmm0
	psrad	$1, %xmm0
	paddd	.LC2(%rip), %xmm0
	paddd	%xmm1, %xmm0
	movups	%xmm0, 16(%r8)
.L5:
	movl	%r9d, %r15d
	cmpl	%edi, %r9d
	je	.L6
.L4:
	leal	(%rax,%r15), %edx
	movl	%eax, %ebp
	movslq	%eax, %rcx
	leal	1(%rdx), %esi
	leaq	(%rcx,%rcx,4), %rcx
	imull	%edx, %esi
	sarl	%esi
	andl	$1, %edx
	movslq	%r15d, %rdx
	cmove	%r15d, %ebp
	addq	%rcx, %rcx
	addq	%rcx, %rdx
	leal	1(%rbp,%rsi), %esi
	movl	%esi, (%rbx,%rdx,4)
	leal	1(%r15), %edx
	cmpl	%edx, %edi
	jle	.L6
	leal	(%rdx,%rax), %ebp
	leal	1(%rbp), %esi
	imull	%ebp, %esi
	sarl	%esi
	andl	$1, %ebp
	movl	%eax, %ebp
	cmove	%edx, %ebp
	movslq	%edx, %rdx
	addl	$2, %r15d
	addq	%rcx, %rdx
	leal	1(%rbp,%rsi), %esi
	movl	%esi, (%rbx,%rdx,4)
	cmpl	%r15d, %edi
	jle	.L6
	leal	(%r15,%rax), %esi
	leal	1(%rsi), %edx
	imull	%esi, %edx
	sarl	%edx
	andl	$1, %esi
	movl	%eax, %esi
	cmove	%r15d, %esi
	movslq	%r15d, %r15
	addq	%r15, %rcx
	leal	1(%rsi,%rdx), %edx
	movl	%edx, (%rbx,%rcx,4)
.L6:
	addl	$1, %eax
	addq	$40, %r8
	cmpl	%edi, %eax
	jne	.L10
	movl	%eax, x(%rip)
.L3:
	movl	c(%rip), %eax
	leaq	.LC5(%rip), %rdi
	leaq	.LC7(%rip), %r12
	leaq	m(%rip), %rbx
	leaq	.LC6(%rip), %rbp
	leal	1(%rax), %esi
	xorl	%eax, %eax
	movl	%esi, c(%rip)
	call	printf@PLT
	movl	N(%rip), %esi
	xorl	%eax, %eax
	movl	$0, x(%rip)
	testl	%esi, %esi
	jle	.L2
	.p2align 4,,10
	.p2align 3
.L11:
	xorl	%r15d, %r15d
	testl	%esi, %esi
	jg	.L16
	jmp	.L15
	.p2align 4,,10
	.p2align 3
.L31:
	cltq
	movslq	%r15d, %rdx
	leaq	(%rax,%rax,4), %rax
	leaq	(%rdx,%rax,2), %rax
	movl	(%rbx,%rax,4), %esi
.L28:
	movq	%rbp, %rdi
	xorl	%eax, %eax
	addl	$1, %r15d
	call	printf@PLT
	movl	N(%rip), %esi
	cmpl	%r15d, %esi
	jle	.L15
	movl	x(%rip), %eax
.L16:
	leal	(%r15,%rax), %edx
	cmpl	%esi, %edx
	jl	.L31
	leal	-1(%rsi), %edx
	movl	%edx, %ecx
	imull	%esi, %esi
	subl	%eax, %edx
	subl	%r15d, %ecx
	movslq	%edx, %rax
	movslq	%ecx, %rcx
	leaq	(%rax,%rax,4), %rax
	leaq	(%rcx,%rax,2), %rax
	addl	$1, %esi
	subl	(%rbx,%rax,4), %esi
	jmp	.L28
	.p2align 4,,10
	.p2align 3
.L15:
	movq	%r12, %rdi
	call	puts@PLT
	movl	x(%rip), %eax
	movl	N(%rip), %esi
	addl	$1, %eax
	movl	%eax, x(%rip)
	cmpl	%esi, %eax
	jl	.L11
	jmp	.L2
	.p2align 4,,10
	.p2align 3
.L18:
	xorl	%r15d, %r15d
	jmp	.L4
.L30:
	call	exit@PLT
	.cfi_endproc
.LFE0:
	.size	main, .-main
	.globl	N
	.bss
	.align 4
	.type	N, @object
	.size	N, 4
N:
	.zero	4
	.globl	x
	.align 4
	.type	x, @object
	.size	x, 4
x:
	.zero	4
	.globl	m
	.align 32
	.type	m, @object
	.size	m, 400
m:
	.zero	400
	.globl	c
	.align 4
	.type	c, @object
	.size	c, 4
c:
	.zero	4
	.section	.rodata.cst16,"aM",@progbits,16
	.align 16
.LC0:
	.long	0
	.long	1
	.long	2
	.long	3
	.align 16
.LC1:
	.long	1
	.long	2
	.long	3
	.long	4
	.align 16
.LC2:
	.long	1
	.long	1
	.long	1
	.long	1
	.align 16
.LC3:
	.long	4
	.long	5
	.long	6
	.long	7
	.align 16
.LC4:
	.long	5
	.long	6
	.long	7
	.long	8
	.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
.LC5:
	.string	"Case %d:\n"
.LC6:
	.string	"%3d"
.LC7:
	.string	""
.LC8:
	.string	"%d"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB0:
	.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
	leaq	N(%rip), %r14
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	leaq	.LC8(%rip), %r13
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$8, %rsp
	.cfi_def_cfa_offset 64
	.p2align 4,,10
	.p2align 3
.L2:
	movq	%r13, %rdi
	movq	%r14, %rsi
	xorl	%eax, %eax
	call	scanf@PLT
	movl	N(%rip), %edi
	testl	%edi, %edi
	je	.L30
	movl	$0, x(%rip)
	jle	.L3
	leaq	m(%rip), %rbx
	movl	%edi, %r11d
	movl	%edi, %r9d
	xorl	%eax, %eax
	movq	%rbx, %r8
	leal	-1(%rdi), %r10d
	shrl	$2, %r11d
	andl	$-4, %r9d
	movdqa	.LC3(%rip), %xmm4
	movdqa	.LC4(%rip), %xmm5
	pxor	%xmm3, %xmm3
	.p2align 4,,10
	.p2align 3
.L10:
	cmpl	$2, %r10d
	jbe	.L18
	movd	%eax, %xmm7
	movdqa	.LC0(%rip), %xmm1
	movdqa	.LC1(%rip), %xmm6
	pshufd	$0, %xmm7, %xmm2
	paddd	%xmm2, %xmm1
	paddd	%xmm2, %xmm6
	movdqa	%xmm1, %xmm7
	movdqa	%xmm6, %xmm0
	psrlq	$32, %xmm7
	psrlq	$32, %xmm6
	pmuludq	%xmm1, %xmm0
	pmuludq	%xmm7, %xmm6
	pand	.LC2(%rip), %xmm1
	pcmpeqd	%xmm3, %xmm1
	pshufd	$8, %xmm6, %xmm6
	pshufd	$8, %xmm0, %xmm0
	punpckldq	%xmm6, %xmm0
	movdqa	.LC0(%rip), %xmm6
	pand	%xmm1, %xmm6
	pandn	%xmm2, %xmm1
	por	%xmm6, %xmm1
	movdqa	%xmm3, %xmm6
	pcmpgtd	%xmm0, %xmm6
	psubd	%xmm6, %xmm0
	psrad	$1, %xmm0
	paddd	.LC2(%rip), %xmm0
	paddd	%xmm1, %xmm0
	movups	%xmm0, (%r8)
	cmpl	$1, %r11d
	jbe	.L5
	movdqa	%xmm2, %xmm1
	movdqa	%xmm2, %xmm6
	paddd	%xmm4, %xmm1
	paddd	%xmm5, %xmm6
	movdqa	%xmm1, %xmm7
	movdqa	%xmm6, %xmm0
	psrlq	$32, %xmm7
	psrlq	$32, %xmm6
	pmuludq	%xmm1, %xmm0
	pmuludq	%xmm7, %xmm6
	pand	.LC2(%rip), %xmm1
	pcmpeqd	%xmm3, %xmm1
	pshufd	$8, %xmm6, %xmm6
	pshufd	$8, %xmm0, %xmm0
	punpckldq	%xmm6, %xmm0
	movdqa	%xmm4, %xmm6
	pand	%xmm1, %xmm6
	pandn	%xmm2, %xmm1
	movdqa	%xmm3, %xmm2
	pcmpgtd	%xmm0, %xmm2
	por	%xmm6, %xmm1
	psubd	%xmm2, %xmm0
	psrad	$1, %xmm0
	paddd	.LC2(%rip), %xmm0
	paddd	%xmm1, %xmm0
	movups	%xmm0, 16(%r8)
.L5:
	movl	%r9d, %r15d
	cmpl	%edi, %r9d
	je	.L6
.L4:
	leal	(%rax,%r15), %edx
	movl	%eax, %ebp
	movslq	%eax, %rcx
	leal	1(%rdx), %esi
	leaq	(%rcx,%rcx,4), %rcx
	imull	%edx, %esi
	sarl	%esi
	andl	$1, %edx
	movslq	%r15d, %rdx
	cmove	%r15d, %ebp
	addq	%rcx, %rcx
	addq	%rcx, %rdx
	leal	1(%rbp,%rsi), %esi
	movl	%esi, (%rbx,%rdx,4)
	leal	1(%r15), %edx
	cmpl	%edx, %edi
	jle	.L6
	leal	(%rdx,%rax), %ebp
	leal	1(%rbp), %esi
	imull	%ebp, %esi
	sarl	%esi
	andl	$1, %ebp
	movl	%eax, %ebp
	cmove	%edx, %ebp
	movslq	%edx, %rdx
	addl	$2, %r15d
	addq	%rcx, %rdx
	leal	1(%rbp,%rsi), %esi
	movl	%esi, (%rbx,%rdx,4)
	cmpl	%r15d, %edi
	jle	.L6
	leal	(%r15,%rax), %esi
	leal	1(%rsi), %edx
	imull	%esi, %edx
	sarl	%edx
	andl	$1, %esi
	movl	%eax, %esi
	cmove	%r15d, %esi
	movslq	%r15d, %r15
	addq	%r15, %rcx
	leal	1(%rsi,%rdx), %edx
	movl	%edx, (%rbx,%rcx,4)
.L6:
	addl	$1, %eax
	addq	$40, %r8
	cmpl	%edi, %eax
	jne	.L10
	movl	%eax, x(%rip)
.L3:
	movl	c(%rip), %eax
	leaq	.LC5(%rip), %rdi
	leaq	.LC7(%rip), %r12
	leaq	m(%rip), %rbx
	leaq	.LC6(%rip), %rbp
	leal	1(%rax), %esi
	xorl	%eax, %eax
	movl	%esi, c(%rip)
	call	printf@PLT
	movl	N(%rip), %esi
	xorl	%eax, %eax
	movl	$0, x(%rip)
	testl	%esi, %esi
	jle	.L2
	.p2align 4,,10
	.p2align 3
.L11:
	xorl	%r15d, %r15d
	testl	%esi, %esi
	jg	.L16
	jmp	.L15
	.p2align 4,,10
	.p2align 3
.L31:
	cltq
	movslq	%r15d, %rdx
	leaq	(%rax,%rax,4), %rax
	leaq	(%rdx,%rax,2), %rax
	movl	(%rbx,%rax,4), %esi
.L28:
	movq	%rbp, %rdi
	xorl	%eax, %eax
	addl	$1, %r15d
	call	printf@PLT
	movl	N(%rip), %esi
	cmpl	%r15d, %esi
	jle	.L15
	movl	x(%rip), %eax
.L16:
	leal	(%r15,%rax), %edx
	cmpl	%esi, %edx
	jl	.L31
	leal	-1(%rsi), %edx
	movl	%edx, %ecx
	imull	%esi, %esi
	subl	%eax, %edx
	subl	%r15d, %ecx
	movslq	%edx, %rax
	movslq	%ecx, %rcx
	leaq	(%rax,%rax,4), %rax
	leaq	(%rcx,%rax,2), %rax
	addl	$1, %esi
	subl	(%rbx,%rax,4), %esi
	jmp	.L28
	.p2align 4,,10
	.p2align 3
.L15:
	movq	%r12, %rdi
	call	puts@PLT
	movl	x(%rip), %eax
	movl	N(%rip), %esi
	addl	$1, %eax
	movl	%eax, x(%rip)
	cmpl	%esi, %eax
	jl	.L11
	jmp	.L2
	.p2align 4,,10
	.p2align 3
.L18:
	xorl	%r15d, %r15d
	jmp	.L4
.L30:
	call	exit@PLT
	.cfi_endproc
.LFE0:
	.size	main, .-main
	.globl	N
	.bss
	.align 4
	.type	N, @object
	.size	N, 4
N:
	.zero	4
	.globl	x
	.align 4
	.type	x, @object
	.size	x, 4
x:
	.zero	4
	.globl	m
	.align 32
	.type	m, @object
	.size	m, 400
m:
	.zero	400
	.globl	c
	.align 4
	.type	c, @object
	.size	c, 4
c:
	.zero	4
	.section	.rodata.cst16,"aM",@progbits,16
	.align 16
.LC0:
	.long	0
	.long	1
	.long	2
	.long	3
	.align 16
.LC1:
	.long	1
	.long	2
	.long	3
	.long	4
	.align 16
.LC2:
	.long	1
	.long	1
	.long	1
	.long	1
	.align 16
.LC3:
	.long	4
	.long	5
	.long	6
	.long	7
	.align 16
.LC4:
	.long	5
	.long	6
	.long	7
	.long	8
	.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:

#define d for(x=0;x<N;x++){for(y=0;y<N;y++
c,m[10][10],x,N;main(y){for(;scanf("%d",&N),N;){d)m[x][y]=(x+y)*(x+y+1)/2+1+(x+y&1?x:y);}printf("Case %d:\n",++c);d)printf("%3d",x+y<N?m[x][y]:N*N+1-m[N-1-x][N-1-y]);puts("");}}exit(0);}
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
#define d for(x=0;x<N;x++){for(y=0;y<N;y++
c,m[10][10],x,N;main(y){for(;scanf("%d",&N),N;){d)m[x][y]=(x+y)*(x+y+1)/2+1+(x+y&1?x:y);}printf("Case %d:\n",++c);d)printf("%3d",x+y<N?m[x][y]:N*N+1-m[N-1-x][N-1-y]);puts("");}}exit(0);}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	c
	.bss
	.align 4
	.type	c, @object
	.size	c, 4
c:
	.zero	4
	.globl	m
	.align 32
	.type	m, @object
	.size	m, 400
m:
	.zero	400
	.globl	x
	.align 4
	.type	x, @object
	.size	x, 4
x:
	.zero	4
	.globl	N
	.align 4
	.type	N, @object
	.size	N, 4
N:
	.zero	4
	.section	.rodata
.LC0:
	.string	"Case %d:\n"
.LC1:
	.string	"%3d"
.LC2:
	.string	""
.LC3:
	.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
	subq	$16, %rsp
	movl	%edi, -4(%rbp)
	jmp	.L2
.L15:
	movl	$0, x(%rip)
	jmp	.L3
.L8:
	movl	$0, -4(%rbp)
	jmp	.L4
.L7:
	movl	x(%rip), %edx
	movl	-4(%rbp), %eax
	addl	%eax, %edx
	movl	x(%rip), %ecx
	movl	-4(%rbp), %eax
	addl	%ecx, %eax
	addl	$1, %eax
	imull	%edx, %eax
	movl	%eax, %edx
	shrl	$31, %edx
	addl	%edx, %eax
	sarl	%eax
	leal	1(%rax), %ecx
	movl	x(%rip), %edx
	movl	-4(%rbp), %eax
	addl	%edx, %eax
	andl	$1, %eax
	testl	%eax, %eax
	je	.L5
	movl	x(%rip), %eax
	jmp	.L6
.L5:
	movl	-4(%rbp), %eax
.L6:
	movl	x(%rip), %edx
	addl	%eax, %ecx
	movl	-4(%rbp), %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	%ecx, (%rdx,%rax)
	addl	$1, -4(%rbp)
.L4:
	movl	N(%rip), %eax
	cmpl	%eax, -4(%rbp)
	jl	.L7
	movl	x(%rip), %eax
	addl	$1, %eax
	movl	%eax, x(%rip)
.L3:
	movl	x(%rip), %edx
	movl	N(%rip), %eax
	cmpl	%eax, %edx
	jl	.L8
	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	.L9
.L14:
	movl	$0, -4(%rbp)
	jmp	.L10
.L13:
	movl	x(%rip), %edx
	movl	-4(%rbp), %eax
	addl	%eax, %edx
	movl	N(%rip), %eax
	cmpl	%eax, %edx
	jge	.L11
	movl	x(%rip), %eax
	movl	-4(%rbp), %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	.L12
.L11:
	movl	N(%rip), %edx
	movl	N(%rip), %eax
	imull	%edx, %eax
	leal	1(%rax), %ecx
	movl	N(%rip), %eax
	subl	$1, %eax
	movl	x(%rip), %esi
	subl	%esi, %eax
	movl	%eax, %edx
	movl	N(%rip), %eax
	subl	$1, %eax
	subl	-4(%rbp), %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
	movl	%ecx, %eax
	subl	%edx, %eax
.L12:
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	addl	$1, -4(%rbp)
.L10:
	movl	N(%rip), %eax
	cmpl	%eax, -4(%rbp)
	jl	.L13
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	movl	x(%rip), %eax
	addl	$1, %eax
	movl	%eax, x(%rip)
.L9:
	movl	x(%rip), %edx
	movl	N(%rip), %eax
	cmpl	%eax, %edx
	jl	.L14
.L2:
	leaq	N(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	scanf@PLT
	movl	N(%rip), %eax
	testl	%eax, %eax
	jne	.L15
	movl	$0, %edi
	call	exit@PLT
	.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	c
	.bss
	.align 4
	.type	c, @object
	.size	c, 4
c:
	.zero	4
	.globl	m
	.align 32
	.type	m, @object
	.size	m, 400
m:
	.zero	400
	.globl	x
	.align 4
	.type	x, @object
	.size	x, 4
x:
	.zero	4
	.globl	N
	.align 4
	.type	N, @object
	.size	N, 4
N:
	.zero	4
	.section	.rodata
.LC0:
	.string	"Case %d:\n"
.LC1:
	.string	"%3d"
.LC2:
	.string	""
.LC3:
	.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
	subq	$16, %rsp
	movl	%edi, -4(%rbp)
	jmp	.L2
.L15:
	movl	$0, x(%rip)
	jmp	.L3
.L8:
	movl	$0, -4(%rbp)
	jmp	.L4
.L7:
	movl	x(%rip), %edx
	movl	-4(%rbp), %eax
	addl	%eax, %edx
	movl	x(%rip), %ecx
	movl	-4(%rbp), %eax
	addl	%ecx, %eax
	addl	$1, %eax
	imull	%edx, %eax
	movl	%eax, %edx
	shrl	$31, %edx
	addl	%edx, %eax
	sarl	%eax
	leal	1(%rax), %ecx
	movl	x(%rip), %edx
	movl	-4(%rbp), %eax
	addl	%edx, %eax
	andl	$1, %eax
	testl	%eax, %eax
	je	.L5
	movl	x(%rip), %eax
	jmp	.L6
.L5:
	movl	-4(%rbp), %eax
.L6:
	movl	x(%rip), %edx
	addl	%eax, %ecx
	movl	-4(%rbp), %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	%ecx, (%rdx,%rax)
	addl	$1, -4(%rbp)
.L4:
	movl	N(%rip), %eax
	cmpl	%eax, -4(%rbp)
	jl	.L7
	movl	x(%rip), %eax
	addl	$1, %eax
	movl	%eax, x(%rip)
.L3:
	movl	x(%rip), %edx
	movl	N(%rip), %eax
	cmpl	%eax, %edx
	jl	.L8
	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	.L9
.L14:
	movl	$0, -4(%rbp)
	jmp	.L10
.L13:
	movl	x(%rip), %edx
	movl	-4(%rbp), %eax
	addl	%eax, %edx
	movl	N(%rip), %eax
	cmpl	%eax, %edx
	jge	.L11
	movl	x(%rip), %eax
	movl	-4(%rbp), %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	.L12
.L11:
	movl	N(%rip), %edx
	movl	N(%rip), %eax
	imull	%edx, %eax
	leal	1(%rax), %ecx
	movl	N(%rip), %eax
	subl	$1, %eax
	movl	x(%rip), %esi
	subl	%esi, %eax
	movl	%eax, %edx
	movl	N(%rip), %eax
	subl	$1, %eax
	subl	-4(%rbp), %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
	movl	%ecx, %eax
	subl	%edx, %eax
.L12:
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	addl	$1, -4(%rbp)
.L10:
	movl	N(%rip), %eax
	cmpl	%eax, -4(%rbp)
	jl	.L13
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	movl	x(%rip), %eax
	addl	$1, %eax
	movl	%eax, x(%rip)
.L9:
	movl	x(%rip), %edx
	movl	N(%rip), %eax
	cmpl	%eax, %edx
	jl	.L14
.L2:
	leaq	N(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	scanf@PLT
	movl	N(%rip), %eax
	testl	%eax, %eax
	jne	.L15
	movl	$0, %edi
	call	exit@PLT
	.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:
