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>

char buffer[4567890];
int buffer2[1234567];

int H, W, K;
int x1, y1, x2, y2;
char* c[1234567];
int* cost[1234567];

int qs, qe;
int q[1234567][2];

int main(void) {
	int i;
	if (fgets(buffer, sizeof(buffer), stdin) == NULL) return 1;
	if (sscanf(buffer, "%d%d%d", &H, &W, &K) != 3) return 1;
	if (fgets(buffer, sizeof(buffer), stdin) == NULL) return 1;
	if (sscanf(buffer, "%d%d%d%d", &x1, &y1, &x2, &y2) != 4) return 1;
	for (i = 0; i < H; i++) {
		c[i] = &buffer[(W + 3) * i];
		cost[i] = &buffer2[W * i];
		if (fgets(c[i], W + 3, stdin) == NULL) return 1;
	}
	q[0][0] = x1 - 1;
	q[0][1] = y1 - 1;
	cost[x1 - 1][y1 - 1] = 1;
	qs = 0;
	qe = 1;
	while (qs < qe) {
		int cy = q[qs][0], cx = q[qs][1];
		int cc = cost[cy][cx];
		qs++;
		for (i = 1; i <= K && cx - i >= 0 && c[cy][cx - i] != '@' && (cost[cy][cx - i] == 0 || cost[cy][cx - i] > cc); i++) {
			if (cost[cy][cx - i] == 0) {
				q[qe][0] = cy;
				q[qe][1] = cx - i;
				qe++;
			}
			cost[cy][cx - i] = cc + 1;
		}
		for (i = 1; i <= K && cx + i < W && c[cy][cx + i] != '@' && (cost[cy][cx + i] == 0 || cost[cy][cx + i] > cc); i++) {
			if (cost[cy][cx + i] == 0) {
				q[qe][0] = cy;
				q[qe][1] = cx + i;
				qe++;
			}
			cost[cy][cx + i] = cc + 1;
		}
		for (i = 1; i <= K && cy - i >= 0 && c[cy - i][cx] != '@' && (cost[cy - i][cx] == 0 || cost[cy - i][cx] > cc); i++) {
			if (cost[cy - i][cx] == 0) {
				q[qe][0] = cy - i;
				q[qe][1] = cx;
				qe++;
			}
			cost[cy - i][cx] = cc + 1;
		}
		for (i = 1; i <= K && cy + i < H && c[cy + i][cx] != '@' && (cost[cy + i][cx] == 0 || cost[cy + i][cx] > cc); i++) {
			if (cost[cy + i][cx] == 0) {
				q[qe][0] = cy + i;
				q[qe][1] = cx;
				qe++;
			}
			cost[cy + i][cx] = cc + 1;
		}
	}
	printf("%d\n", cost[x2 - 1][y2 - 1] - 1);
	return 0;
}
```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	buffer
	.bss
	.align 32
	.type	buffer, @object
	.size	buffer, 4567890
buffer:
	.zero	4567890
	.globl	buffer2
	.align 32
	.type	buffer2, @object
	.size	buffer2, 4938268
buffer2:
	.zero	4938268
	.globl	H
	.align 4
	.type	H, @object
	.size	H, 4
H:
	.zero	4
	.globl	W
	.align 4
	.type	W, @object
	.size	W, 4
W:
	.zero	4
	.globl	K
	.align 4
	.type	K, @object
	.size	K, 4
K:
	.zero	4
	.globl	x1
	.align 4
	.type	x1, @object
	.size	x1, 4
x1:
	.zero	4
	.globl	y1
	.align 4
	.type	y1, @object
	.size	y1, 4
y1:
	.zero	4
	.globl	x2
	.align 4
	.type	x2, @object
	.size	x2, 4
x2:
	.zero	4
	.globl	y2
	.align 4
	.type	y2, @object
	.size	y2, 4
y2:
	.zero	4
	.globl	c
	.align 32
	.type	c, @object
	.size	c, 9876536
c:
	.zero	9876536
	.globl	cost
	.align 32
	.type	cost, @object
	.size	cost, 9876536
cost:
	.zero	9876536
	.globl	qs
	.align 4
	.type	qs, @object
	.size	qs, 4
qs:
	.zero	4
	.globl	qe
	.align 4
	.type	qe, @object
	.size	qe, 4
qe:
	.zero	4
	.globl	q
	.align 32
	.type	q, @object
	.size	q, 9876536
q:
	.zero	9876536
	.section	.rodata
.LC0:
	.string	"%d%d%d"
.LC1:
	.string	"%d%d%d%d"
.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
	subq	$16, %rsp
	movq	stdin(%rip), %rax
	movq	%rax, %rdx
	movl	$4567890, %esi
	leaq	buffer(%rip), %rax
	movq	%rax, %rdi
	call	fgets@PLT
	testq	%rax, %rax
	jne	.L2
	movl	$1, %eax
	jmp	.L3
.L2:
	leaq	K(%rip), %r8
	leaq	W(%rip), %rax
	movq	%rax, %rcx
	leaq	H(%rip), %rax
	movq	%rax, %rdx
	leaq	.LC0(%rip), %rax
	movq	%rax, %rsi
	leaq	buffer(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_sscanf@PLT
	cmpl	$3, %eax
	je	.L4
	movl	$1, %eax
	jmp	.L3
.L4:
	movq	stdin(%rip), %rax
	movq	%rax, %rdx
	movl	$4567890, %esi
	leaq	buffer(%rip), %rax
	movq	%rax, %rdi
	call	fgets@PLT
	testq	%rax, %rax
	jne	.L5
	movl	$1, %eax
	jmp	.L3
.L5:
	leaq	y2(%rip), %r9
	leaq	x2(%rip), %r8
	leaq	y1(%rip), %rax
	movq	%rax, %rcx
	leaq	x1(%rip), %rax
	movq	%rax, %rdx
	leaq	.LC1(%rip), %rax
	movq	%rax, %rsi
	leaq	buffer(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_sscanf@PLT
	cmpl	$4, %eax
	je	.L6
	movl	$1, %eax
	jmp	.L3
.L6:
	movl	$0, -16(%rbp)
	jmp	.L7
.L9:
	movl	W(%rip), %eax
	addl	$3, %eax
	imull	-16(%rbp), %eax
	cltq
	leaq	buffer(%rip), %rdx
	leaq	(%rax,%rdx), %rcx
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	c(%rip), %rax
	movq	%rcx, (%rdx,%rax)
	movl	W(%rip), %eax
	imull	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	buffer2(%rip), %rax
	leaq	(%rdx,%rax), %rcx
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	cost(%rip), %rax
	movq	%rcx, (%rdx,%rax)
	movq	stdin(%rip), %rdx
	movl	W(%rip), %eax
	leal	3(%rax), %ecx
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rsi
	leaq	c(%rip), %rax
	movq	(%rsi,%rax), %rax
	movl	%ecx, %esi
	movq	%rax, %rdi
	call	fgets@PLT
	testq	%rax, %rax
	jne	.L8
	movl	$1, %eax
	jmp	.L3
.L8:
	addl	$1, -16(%rbp)
.L7:
	movl	H(%rip), %eax
	cmpl	%eax, -16(%rbp)
	jl	.L9
	movl	x1(%rip), %eax
	subl	$1, %eax
	movl	%eax, q(%rip)
	movl	y1(%rip), %eax
	subl	$1, %eax
	movl	%eax, 4+q(%rip)
	movl	x1(%rip), %eax
	subl	$1, %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	cost(%rip), %rax
	movq	(%rdx,%rax), %rdx
	movl	y1(%rip), %eax
	cltq
	salq	$2, %rax
	subq	$4, %rax
	addq	%rdx, %rax
	movl	$1, (%rax)
	movl	$0, qs(%rip)
	movl	$1, qe(%rip)
	jmp	.L10
.L26:
	movl	qs(%rip), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	q(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -12(%rbp)
	movl	qs(%rip), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	4+q(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -8(%rbp)
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	cost(%rip), %rax
	movq	(%rdx,%rax), %rdx
	movl	-8(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	movl	%eax, -4(%rbp)
	movl	qs(%rip), %eax
	addl	$1, %eax
	movl	%eax, qs(%rip)
	movl	$1, -16(%rbp)
	jmp	.L11
.L14:
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	cost(%rip), %rax
	movq	(%rdx,%rax), %rdx
	movl	-8(%rbp), %eax
	subl	-16(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	testl	%eax, %eax
	jne	.L12
	movl	qe(%rip), %eax
	cltq
	leaq	0(,%rax,8), %rcx
	leaq	q(%rip), %rdx
	movl	-12(%rbp), %eax
	movl	%eax, (%rcx,%rdx)
	movl	qe(%rip), %edx
	movl	-8(%rbp), %eax
	subl	-16(%rbp), %eax
	movslq	%edx, %rdx
	leaq	0(,%rdx,8), %rcx
	leaq	4+q(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	movl	qe(%rip), %eax
	addl	$1, %eax
	movl	%eax, qe(%rip)
.L12:
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	cost(%rip), %rax
	movq	(%rdx,%rax), %rdx
	movl	-8(%rbp), %eax
	subl	-16(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rdx, %rax
	movl	-4(%rbp), %edx
	addl	$1, %edx
	movl	%edx, (%rax)
	addl	$1, -16(%rbp)
.L11:
	movl	K(%rip), %eax
	cmpl	%eax, -16(%rbp)
	jg	.L13
	movl	-8(%rbp), %eax
	subl	-16(%rbp), %eax
	testl	%eax, %eax
	js	.L13
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	c(%rip), %rax
	movq	(%rdx,%rax), %rdx
	movl	-8(%rbp), %eax
	subl	-16(%rbp), %eax
	cltq
	addq	%rdx, %rax
	movzbl	(%rax), %eax
	cmpb	$64, %al
	je	.L13
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	cost(%rip), %rax
	movq	(%rdx,%rax), %rdx
	movl	-8(%rbp), %eax
	subl	-16(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	testl	%eax, %eax
	je	.L14
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	cost(%rip), %rax
	movq	(%rdx,%rax), %rdx
	movl	-8(%rbp), %eax
	subl	-16(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	cmpl	%eax, -4(%rbp)
	jl	.L14
.L13:
	movl	$1, -16(%rbp)
	jmp	.L15
.L18:
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	cost(%rip), %rax
	movq	(%rdx,%rax), %rdx
	movl	-8(%rbp), %ecx
	movl	-16(%rbp), %eax
	addl	%ecx, %eax
	cltq
	salq	$2, %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	testl	%eax, %eax
	jne	.L16
	movl	qe(%rip), %eax
	cltq
	leaq	0(,%rax,8), %rcx
	leaq	q(%rip), %rdx
	movl	-12(%rbp), %eax
	movl	%eax, (%rcx,%rdx)
	movl	qe(%rip), %eax
	movl	-8(%rbp), %ecx
	movl	-16(%rbp), %edx
	addl	%edx, %ecx
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	4+q(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	movl	qe(%rip), %eax
	addl	$1, %eax
	movl	%eax, qe(%rip)
.L16:
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	cost(%rip), %rax
	movq	(%rdx,%rax), %rdx
	movl	-8(%rbp), %ecx
	movl	-16(%rbp), %eax
	addl	%ecx, %eax
	cltq
	salq	$2, %rax
	addq	%rdx, %rax
	movl	-4(%rbp), %edx
	addl	$1, %edx
	movl	%edx, (%rax)
	addl	$1, -16(%rbp)
.L15:
	movl	K(%rip), %eax
	cmpl	%eax, -16(%rbp)
	jg	.L17
	movl	-8(%rbp), %edx
	movl	-16(%rbp), %eax
	addl	%eax, %edx
	movl	W(%rip), %eax
	cmpl	%eax, %edx
	jge	.L17
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	c(%rip), %rax
	movq	(%rdx,%rax), %rdx
	movl	-8(%rbp), %ecx
	movl	-16(%rbp), %eax
	addl	%ecx, %eax
	cltq
	addq	%rdx, %rax
	movzbl	(%rax), %eax
	cmpb	$64, %al
	je	.L17
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	cost(%rip), %rax
	movq	(%rdx,%rax), %rdx
	movl	-8(%rbp), %ecx
	movl	-16(%rbp), %eax
	addl	%ecx, %eax
	cltq
	salq	$2, %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	testl	%eax, %eax
	je	.L18
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	cost(%rip), %rax
	movq	(%rdx,%rax), %rdx
	movl	-8(%rbp), %ecx
	movl	-16(%rbp), %eax
	addl	%ecx, %eax
	cltq
	salq	$2, %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	cmpl	%eax, -4(%rbp)
	jl	.L18
.L17:
	movl	$1, -16(%rbp)
	jmp	.L19
.L22:
	movl	-12(%rbp), %eax
	subl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	cost(%rip), %rax
	movq	(%rdx,%rax), %rdx
	movl	-8(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	testl	%eax, %eax
	jne	.L20
	movl	qe(%rip), %edx
	movl	-12(%rbp), %eax
	subl	-16(%rbp), %eax
	movslq	%edx, %rdx
	leaq	0(,%rdx,8), %rcx
	leaq	q(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	movl	qe(%rip), %eax
	cltq
	leaq	0(,%rax,8), %rcx
	leaq	4+q(%rip), %rdx
	movl	-8(%rbp), %eax
	movl	%eax, (%rcx,%rdx)
	movl	qe(%rip), %eax
	addl	$1, %eax
	movl	%eax, qe(%rip)
.L20:
	movl	-12(%rbp), %eax
	subl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	cost(%rip), %rax
	movq	(%rdx,%rax), %rdx
	movl	-8(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rdx, %rax
	movl	-4(%rbp), %edx
	addl	$1, %edx
	movl	%edx, (%rax)
	addl	$1, -16(%rbp)
.L19:
	movl	K(%rip), %eax
	cmpl	%eax, -16(%rbp)
	jg	.L21
	movl	-12(%rbp), %eax
	subl	-16(%rbp), %eax
	testl	%eax, %eax
	js	.L21
	movl	-12(%rbp), %eax
	subl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	c(%rip), %rax
	movq	(%rdx,%rax), %rdx
	movl	-8(%rbp), %eax
	cltq
	addq	%rdx, %rax
	movzbl	(%rax), %eax
	cmpb	$64, %al
	je	.L21
	movl	-12(%rbp), %eax
	subl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	cost(%rip), %rax
	movq	(%rdx,%rax), %rdx
	movl	-8(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	testl	%eax, %eax
	je	.L22
	movl	-12(%rbp), %eax
	subl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	cost(%rip), %rax
	movq	(%rdx,%rax), %rdx
	movl	-8(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	cmpl	%eax, -4(%rbp)
	jl	.L22
.L21:
	movl	$1, -16(%rbp)
	jmp	.L23
.L25:
	movl	-12(%rbp), %edx
	movl	-16(%rbp), %eax
	addl	%edx, %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	cost(%rip), %rax
	movq	(%rdx,%rax), %rdx
	movl	-8(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	testl	%eax, %eax
	jne	.L24
	movl	qe(%rip), %eax
	movl	-12(%rbp), %ecx
	movl	-16(%rbp), %edx
	addl	%edx, %ecx
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	q(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	movl	qe(%rip), %eax
	cltq
	leaq	0(,%rax,8), %rcx
	leaq	4+q(%rip), %rdx
	movl	-8(%rbp), %eax
	movl	%eax, (%rcx,%rdx)
	movl	qe(%rip), %eax
	addl	$1, %eax
	movl	%eax, qe(%rip)
.L24:
	movl	-12(%rbp), %edx
	movl	-16(%rbp), %eax
	addl	%edx, %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	cost(%rip), %rax
	movq	(%rdx,%rax), %rdx
	movl	-8(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rdx, %rax
	movl	-4(%rbp), %edx
	addl	$1, %edx
	movl	%edx, (%rax)
	addl	$1, -16(%rbp)
.L23:
	movl	K(%rip), %eax
	cmpl	%eax, -16(%rbp)
	jg	.L10
	movl	-12(%rbp), %edx
	movl	-16(%rbp), %eax
	addl	%eax, %edx
	movl	H(%rip), %eax
	cmpl	%eax, %edx
	jge	.L10
	movl	-12(%rbp), %edx
	movl	-16(%rbp), %eax
	addl	%edx, %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	c(%rip), %rax
	movq	(%rdx,%rax), %rdx
	movl	-8(%rbp), %eax
	cltq
	addq	%rdx, %rax
	movzbl	(%rax), %eax
	cmpb	$64, %al
	je	.L10
	movl	-12(%rbp), %edx
	movl	-16(%rbp), %eax
	addl	%edx, %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	cost(%rip), %rax
	movq	(%rdx,%rax), %rdx
	movl	-8(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	testl	%eax, %eax
	je	.L25
	movl	-12(%rbp), %edx
	movl	-16(%rbp), %eax
	addl	%edx, %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	cost(%rip), %rax
	movq	(%rdx,%rax), %rdx
	movl	-8(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	cmpl	%eax, -4(%rbp)
	jl	.L25
.L10:
	movl	qs(%rip), %edx
	movl	qe(%rip), %eax
	cmpl	%eax, %edx
	jl	.L26
	movl	x2(%rip), %eax
	subl	$1, %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	cost(%rip), %rax
	movq	(%rdx,%rax), %rdx
	movl	y2(%rip), %eax
	cltq
	salq	$2, %rax
	subq	$4, %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	subl	$1, %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
.L3:
	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%d%d"
.LC1:
	.string	"%d%d%d%d"
.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
	movl	$4567890, %esi
	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
	leaq	buffer(%rip), %r12
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	movq	%r12, %rdi
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$8, %rsp
	.cfi_def_cfa_offset 64
	movq	stdin(%rip), %rdx
	call	fgets@PLT
	testq	%rax, %rax
	je	.L4
	xorl	%eax, %eax
	leaq	K(%rip), %r8
	leaq	W(%rip), %rcx
	movq	%r12, %rdi
	leaq	H(%rip), %rdx
	leaq	.LC0(%rip), %rsi
	call	__isoc99_sscanf@PLT
	cmpl	$3, %eax
	je	.L60
.L4:
	movl	$1, %eax
.L1:
	addq	$8, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
.L60:
	.cfi_restore_state
	movq	stdin(%rip), %rdx
	movl	$4567890, %esi
	movq	%r12, %rdi
	call	fgets@PLT
	testq	%rax, %rax
	je	.L4
	xorl	%eax, %eax
	leaq	y2(%rip), %r9
	leaq	x2(%rip), %r8
	movq	%r12, %rdi
	leaq	y1(%rip), %rcx
	leaq	x1(%rip), %rdx
	leaq	.LC1(%rip), %rsi
	call	__isoc99_sscanf@PLT
	cmpl	$4, %eax
	jne	.L4
	xorl	%ebp, %ebp
	cmpl	$0, H(%rip)
	leaq	cost(%rip), %rbx
	leaq	c(%rip), %r14
	leaq	buffer2(%rip), %r13
	jg	.L5
	jmp	.L7
.L61:
	addq	$1, %rbp
	cmpl	%ebp, H(%rip)
	jle	.L7
.L5:
	movl	W(%rip), %eax
	leal	0(%rbp,%rbp,2), %ecx
	movq	$-1, %rsi
	leal	3(%rax), %edx
	movl	%edx, %eax
	imull	%ebp, %eax
	movslq	%eax, %rdi
	subl	%ecx, %eax
	movq	stdin(%rip), %rcx
	addq	%r12, %rdi
	cltq
	movq	%rdi, (%r14,%rbp,8)
	leaq	0(%r13,%rax,4), %rax
	movq	%rax, (%rbx,%rbp,8)
	call	__fgets_chk@PLT
	testq	%rax, %rax
	jne	.L61
	jmp	.L4
.L7:
	movl	x1(%rip), %eax
	movslq	y1(%rip), %rdx
	leaq	q(%rip), %r9
	leaq	c(%rip), %r8
	subl	$1, %eax
	leal	-1(%rdx), %ecx
	movl	%eax, q(%rip)
	cltq
	movq	(%rbx,%rax,8), %rax
	movl	%ecx, 4+q(%rip)
	movl	$1, -4(%rax,%rdx,4)
	xorl	%eax, %eax
	movl	$0, qs(%rip)
	movl	$1, qe(%rip)
.L6:
	movslq	%eax, %rdx
	addl	$1, %eax
	cmpl	$0, K(%rip)
	movd	(%r9,%rdx,8), %xmm0
	movd	4(%r9,%rdx,8), %xmm1
	movd	%xmm0, %edi
	movslq	%edi, %r11
	movd	%xmm1, %edi
	movq	(%rbx,%r11,8), %rcx
	movslq	%edi, %rsi
	leaq	0(,%rsi,4), %r10
	movl	(%rcx,%rsi,4), %edi
	movl	%eax, qs(%rip)
	jle	.L25
	movd	%xmm1, %eax
	subl	$1, %eax
	js	.L62
	movd	%xmm1, %edx
	movq	(%r8,%r11,8), %r13
	cltq
	leal	1(%rdi), %r14d
	leal	1(%rdx), %ebp
	jmp	.L10
	.p2align 4,,10
	.p2align 3
.L63:
	cmpl	%edi, %edx
	jle	.L13
.L15:
	movl	%ebp, %r15d
	movl	%r14d, (%rcx,%rax,4)
	movl	%ebp, %edx
	subl	%r12d, %r15d
	cmpl	%r15d, K(%rip)
	jl	.L13
	subq	$1, %rax
	testl	%eax, %eax
	js	.L12
.L10:
	movdqa	%xmm0, %xmm2
	movd	%eax, %xmm4
	cmpb	$64, 0(%r13,%rax)
	movl	%eax, %r12d
	punpckldq	%xmm4, %xmm2
	je	.L13
	movl	(%rcx,%rax,4), %edx
	testl	%edx, %edx
	jne	.L63
	movslq	qe(%rip), %r15
	movq	%r15, %rdx
	movq	%xmm2, (%r9,%r15,8)
	addl	$1, %edx
	movl	%edx, qe(%rip)
	jmp	.L15
.L13:
	movd	%xmm1, %eax
	cmpl	$0, K(%rip)
	leal	1(%rax), %edx
	jg	.L12
.L25:
	movl	qs(%rip), %eax
	cmpl	qe(%rip), %eax
	jl	.L6
	movl	x2(%rip), %eax
	movslq	y2(%rip), %rdx
	movl	$1, %edi
	leaq	.LC2(%rip), %rsi
	subl	$1, %eax
	cltq
	movq	(%rbx,%rax,8), %rax
	movl	-4(%rax,%rdx,4), %edx
	xorl	%eax, %eax
	subl	$1, %edx
	call	__printf_chk@PLT
	xorl	%eax, %eax
	jmp	.L1
.L62:
	movd	%xmm1, %eax
	leal	1(%rax), %edx
.L12:
	leaq	1(%rsi), %rax
	leal	1(%rdi), %r12d
	jmp	.L16
	.p2align 4,,10
	.p2align 3
.L64:
	cmpl	%edi, %ebp
	jle	.L20
.L22:
	movl	%r12d, (%rcx,%rax,4)
	addq	$1, %rax
	addl	$1, %edx
	movl	%eax, %ebp
	subl	%esi, %ebp
	cmpl	%ebp, K(%rip)
	jl	.L20
.L16:
	movdqa	%xmm0, %xmm2
	movd	%edx, %xmm3
	cmpl	W(%rip), %edx
	punpckldq	%xmm3, %xmm2
	jge	.L20
	movq	(%r8,%r11,8), %rbp
	cmpb	$64, 0(%rbp,%rax)
	je	.L20
	movl	(%rcx,%rax,4), %ebp
	testl	%ebp, %ebp
	jne	.L64
	movslq	qe(%rip), %r13
	movq	%r13, %rbp
	movq	%xmm2, (%r9,%r13,8)
	addl	$1, %ebp
	movl	%ebp, qe(%rip)
	jmp	.L22
.L20:
	cmpl	$0, K(%rip)
	jle	.L25
	movd	%xmm0, %eax
	subl	$1, %eax
	js	.L65
	movd	%xmm0, %ecx
	cltq
	leal	1(%rdi), %r13d
	leal	1(%rcx), %ebp
	jmp	.L19
	.p2align 4,,10
	.p2align 3
.L66:
	cmpl	%edi, %ecx
	jle	.L26
.L28:
	movl	%r13d, (%rdx)
	movl	%ebp, %edx
	movl	%ebp, %ecx
	subl	%r12d, %edx
	cmpl	%edx, K(%rip)
	jl	.L26
	subq	$1, %rax
	testl	%eax, %eax
	js	.L24
.L19:
	movq	(%r8,%rax,8), %rdx
	movd	%eax, %xmm2
	movl	%eax, %r12d
	punpckldq	%xmm1, %xmm2
	cmpb	$64, (%rdx,%rsi)
	je	.L26
	movq	(%rbx,%rax,8), %rdx
	addq	%r10, %rdx
	movl	(%rdx), %ecx
	testl	%ecx, %ecx
	jne	.L66
	movslq	qe(%rip), %r14
	movq	%r14, %rcx
	movq	%xmm2, (%r9,%r14,8)
	addl	$1, %ecx
	movl	%ecx, qe(%rip)
	jmp	.L28
.L26:
	movd	%xmm0, %eax
	cmpl	$0, K(%rip)
	leal	1(%rax), %ecx
	jle	.L25
.L24:
	salq	$3, %r11
	movl	%ecx, %eax
	leal	1(%rdi), %r13d
	movl	$1, %edx
	leaq	(%r8,%r11), %r12
	addq	%rbx, %r11
	jmp	.L31
	.p2align 4,,10
	.p2align 3
.L67:
	cmpl	%edi, %ebp
	jle	.L25
.L30:
	movl	%r13d, (%rcx)
	addq	$1, %rdx
	addl	$1, %eax
	cmpl	%edx, K(%rip)
	jl	.L25
.L31:
	movd	%eax, %xmm0
	cmpl	H(%rip), %eax
	punpckldq	%xmm1, %xmm0
	jge	.L25
	movq	(%r12,%rdx,8), %rcx
	cmpb	$64, (%rcx,%rsi)
	je	.L25
	movq	(%r11,%rdx,8), %rcx
	addq	%r10, %rcx
	movl	(%rcx), %ebp
	testl	%ebp, %ebp
	jne	.L67
	movslq	qe(%rip), %r14
	movq	%r14, %rbp
	movq	%xmm0, (%r9,%r14,8)
	addl	$1, %ebp
	movl	%ebp, qe(%rip)
	jmp	.L30
.L65:
	movd	%xmm0, %eax
	leal	1(%rax), %ecx
	jmp	.L24
	.cfi_endproc
.LFE23:
	.size	main, .-main
	.globl	q
	.bss
	.align 32
	.type	q, @object
	.size	q, 9876536
q:
	.zero	9876536
	.globl	qe
	.align 4
	.type	qe, @object
	.size	qe, 4
qe:
	.zero	4
	.globl	qs
	.align 4
	.type	qs, @object
	.size	qs, 4
qs:
	.zero	4
	.globl	cost
	.align 32
	.type	cost, @object
	.size	cost, 9876536
cost:
	.zero	9876536
	.globl	c
	.align 32
	.type	c, @object
	.size	c, 9876536
c:
	.zero	9876536
	.globl	y2
	.align 4
	.type	y2, @object
	.size	y2, 4
y2:
	.zero	4
	.globl	x2
	.align 4
	.type	x2, @object
	.size	x2, 4
x2:
	.zero	4
	.globl	y1
	.align 4
	.type	y1, @object
	.size	y1, 4
y1:
	.zero	4
	.globl	x1
	.align 4
	.type	x1, @object
	.size	x1, 4
x1:
	.zero	4
	.globl	K
	.align 4
	.type	K, @object
	.size	K, 4
K:
	.zero	4
	.globl	W
	.align 4
	.type	W, @object
	.size	W, 4
W:
	.zero	4
	.globl	H
	.align 4
	.type	H, @object
	.size	H, 4
H:
	.zero	4
	.globl	buffer2
	.align 32
	.type	buffer2, @object
	.size	buffer2, 4938268
buffer2:
	.zero	4938268
	.globl	buffer
	.align 32
	.type	buffer, @object
	.size	buffer, 4567890
buffer:
	.zero	4567890
	.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%d%d"
.LC1:
	.string	"%d%d%d%d"
.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
	movl	$4567890, %esi
	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
	leaq	buffer(%rip), %r12
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	movq	%r12, %rdi
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$8, %rsp
	.cfi_def_cfa_offset 64
	movq	stdin(%rip), %rdx
	call	fgets@PLT
	testq	%rax, %rax
	je	.L4
	xorl	%eax, %eax
	leaq	K(%rip), %r8
	leaq	W(%rip), %rcx
	movq	%r12, %rdi
	leaq	H(%rip), %rdx
	leaq	.LC0(%rip), %rsi
	call	__isoc99_sscanf@PLT
	cmpl	$3, %eax
	je	.L60
.L4:
	movl	$1, %eax
.L1:
	addq	$8, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
.L60:
	.cfi_restore_state
	movq	stdin(%rip), %rdx
	movl	$4567890, %esi
	movq	%r12, %rdi
	call	fgets@PLT
	testq	%rax, %rax
	je	.L4
	xorl	%eax, %eax
	leaq	y2(%rip), %r9
	leaq	x2(%rip), %r8
	movq	%r12, %rdi
	leaq	y1(%rip), %rcx
	leaq	x1(%rip), %rdx
	leaq	.LC1(%rip), %rsi
	call	__isoc99_sscanf@PLT
	cmpl	$4, %eax
	jne	.L4
	xorl	%ebp, %ebp
	cmpl	$0, H(%rip)
	leaq	cost(%rip), %rbx
	leaq	c(%rip), %r14
	leaq	buffer2(%rip), %r13
	jg	.L5
	jmp	.L7
.L61:
	addq	$1, %rbp
	cmpl	%ebp, H(%rip)
	jle	.L7
.L5:
	movl	W(%rip), %eax
	leal	0(%rbp,%rbp,2), %ecx
	movq	$-1, %rsi
	leal	3(%rax), %edx
	movl	%edx, %eax
	imull	%ebp, %eax
	movslq	%eax, %rdi
	subl	%ecx, %eax
	movq	stdin(%rip), %rcx
	addq	%r12, %rdi
	cltq
	movq	%rdi, (%r14,%rbp,8)
	leaq	0(%r13,%rax,4), %rax
	movq	%rax, (%rbx,%rbp,8)
	call	__fgets_chk@PLT
	testq	%rax, %rax
	jne	.L61
	jmp	.L4
.L7:
	movl	x1(%rip), %eax
	movslq	y1(%rip), %rdx
	leaq	q(%rip), %r9
	leaq	c(%rip), %r8
	subl	$1, %eax
	leal	-1(%rdx), %ecx
	movl	%eax, q(%rip)
	cltq
	movq	(%rbx,%rax,8), %rax
	movl	%ecx, 4+q(%rip)
	movl	$1, -4(%rax,%rdx,4)
	xorl	%eax, %eax
	movl	$0, qs(%rip)
	movl	$1, qe(%rip)
.L6:
	movslq	%eax, %rdx
	addl	$1, %eax
	cmpl	$0, K(%rip)
	movd	(%r9,%rdx,8), %xmm0
	movd	4(%r9,%rdx,8), %xmm1
	movd	%xmm0, %edi
	movslq	%edi, %r11
	movd	%xmm1, %edi
	movq	(%rbx,%r11,8), %rcx
	movslq	%edi, %rsi
	leaq	0(,%rsi,4), %r10
	movl	(%rcx,%rsi,4), %edi
	movl	%eax, qs(%rip)
	jle	.L25
	movd	%xmm1, %eax
	subl	$1, %eax
	js	.L62
	movd	%xmm1, %edx
	movq	(%r8,%r11,8), %r13
	cltq
	leal	1(%rdi), %r14d
	leal	1(%rdx), %ebp
	jmp	.L10
	.p2align 4,,10
	.p2align 3
.L63:
	cmpl	%edi, %edx
	jle	.L13
.L15:
	movl	%ebp, %r15d
	movl	%r14d, (%rcx,%rax,4)
	movl	%ebp, %edx
	subl	%r12d, %r15d
	cmpl	%r15d, K(%rip)
	jl	.L13
	subq	$1, %rax
	testl	%eax, %eax
	js	.L12
.L10:
	movdqa	%xmm0, %xmm2
	movd	%eax, %xmm4
	cmpb	$64, 0(%r13,%rax)
	movl	%eax, %r12d
	punpckldq	%xmm4, %xmm2
	je	.L13
	movl	(%rcx,%rax,4), %edx
	testl	%edx, %edx
	jne	.L63
	movslq	qe(%rip), %r15
	movq	%r15, %rdx
	movq	%xmm2, (%r9,%r15,8)
	addl	$1, %edx
	movl	%edx, qe(%rip)
	jmp	.L15
.L13:
	movd	%xmm1, %eax
	cmpl	$0, K(%rip)
	leal	1(%rax), %edx
	jg	.L12
.L25:
	movl	qs(%rip), %eax
	cmpl	qe(%rip), %eax
	jl	.L6
	movl	x2(%rip), %eax
	movslq	y2(%rip), %rdx
	movl	$1, %edi
	leaq	.LC2(%rip), %rsi
	subl	$1, %eax
	cltq
	movq	(%rbx,%rax,8), %rax
	movl	-4(%rax,%rdx,4), %edx
	xorl	%eax, %eax
	subl	$1, %edx
	call	__printf_chk@PLT
	xorl	%eax, %eax
	jmp	.L1
.L62:
	movd	%xmm1, %eax
	leal	1(%rax), %edx
.L12:
	leaq	1(%rsi), %rax
	leal	1(%rdi), %r12d
	jmp	.L16
	.p2align 4,,10
	.p2align 3
.L64:
	cmpl	%edi, %ebp
	jle	.L20
.L22:
	movl	%r12d, (%rcx,%rax,4)
	addq	$1, %rax
	addl	$1, %edx
	movl	%eax, %ebp
	subl	%esi, %ebp
	cmpl	%ebp, K(%rip)
	jl	.L20
.L16:
	movdqa	%xmm0, %xmm2
	movd	%edx, %xmm3
	cmpl	W(%rip), %edx
	punpckldq	%xmm3, %xmm2
	jge	.L20
	movq	(%r8,%r11,8), %rbp
	cmpb	$64, 0(%rbp,%rax)
	je	.L20
	movl	(%rcx,%rax,4), %ebp
	testl	%ebp, %ebp
	jne	.L64
	movslq	qe(%rip), %r13
	movq	%r13, %rbp
	movq	%xmm2, (%r9,%r13,8)
	addl	$1, %ebp
	movl	%ebp, qe(%rip)
	jmp	.L22
.L20:
	cmpl	$0, K(%rip)
	jle	.L25
	movd	%xmm0, %eax
	subl	$1, %eax
	js	.L65
	movd	%xmm0, %ecx
	cltq
	leal	1(%rdi), %r13d
	leal	1(%rcx), %ebp
	jmp	.L19
	.p2align 4,,10
	.p2align 3
.L66:
	cmpl	%edi, %ecx
	jle	.L26
.L28:
	movl	%r13d, (%rdx)
	movl	%ebp, %edx
	movl	%ebp, %ecx
	subl	%r12d, %edx
	cmpl	%edx, K(%rip)
	jl	.L26
	subq	$1, %rax
	testl	%eax, %eax
	js	.L24
.L19:
	movq	(%r8,%rax,8), %rdx
	movd	%eax, %xmm2
	movl	%eax, %r12d
	punpckldq	%xmm1, %xmm2
	cmpb	$64, (%rdx,%rsi)
	je	.L26
	movq	(%rbx,%rax,8), %rdx
	addq	%r10, %rdx
	movl	(%rdx), %ecx
	testl	%ecx, %ecx
	jne	.L66
	movslq	qe(%rip), %r14
	movq	%r14, %rcx
	movq	%xmm2, (%r9,%r14,8)
	addl	$1, %ecx
	movl	%ecx, qe(%rip)
	jmp	.L28
.L26:
	movd	%xmm0, %eax
	cmpl	$0, K(%rip)
	leal	1(%rax), %ecx
	jle	.L25
.L24:
	salq	$3, %r11
	movl	%ecx, %eax
	leal	1(%rdi), %r13d
	movl	$1, %edx
	leaq	(%r8,%r11), %r12
	addq	%rbx, %r11
	jmp	.L31
	.p2align 4,,10
	.p2align 3
.L67:
	cmpl	%edi, %ebp
	jle	.L25
.L30:
	movl	%r13d, (%rcx)
	addq	$1, %rdx
	addl	$1, %eax
	cmpl	%edx, K(%rip)
	jl	.L25
.L31:
	movd	%eax, %xmm0
	cmpl	H(%rip), %eax
	punpckldq	%xmm1, %xmm0
	jge	.L25
	movq	(%r12,%rdx,8), %rcx
	cmpb	$64, (%rcx,%rsi)
	je	.L25
	movq	(%r11,%rdx,8), %rcx
	addq	%r10, %rcx
	movl	(%rcx), %ebp
	testl	%ebp, %ebp
	jne	.L67
	movslq	qe(%rip), %r14
	movq	%r14, %rbp
	movq	%xmm0, (%r9,%r14,8)
	addl	$1, %ebp
	movl	%ebp, qe(%rip)
	jmp	.L30
.L65:
	movd	%xmm0, %eax
	leal	1(%rax), %ecx
	jmp	.L24
	.cfi_endproc
.LFE23:
	.size	main, .-main
	.globl	q
	.bss
	.align 32
	.type	q, @object
	.size	q, 9876536
q:
	.zero	9876536
	.globl	qe
	.align 4
	.type	qe, @object
	.size	qe, 4
qe:
	.zero	4
	.globl	qs
	.align 4
	.type	qs, @object
	.size	qs, 4
qs:
	.zero	4
	.globl	cost
	.align 32
	.type	cost, @object
	.size	cost, 9876536
cost:
	.zero	9876536
	.globl	c
	.align 32
	.type	c, @object
	.size	c, 9876536
c:
	.zero	9876536
	.globl	y2
	.align 4
	.type	y2, @object
	.size	y2, 4
y2:
	.zero	4
	.globl	x2
	.align 4
	.type	x2, @object
	.size	x2, 4
x2:
	.zero	4
	.globl	y1
	.align 4
	.type	y1, @object
	.size	y1, 4
y1:
	.zero	4
	.globl	x1
	.align 4
	.type	x1, @object
	.size	x1, 4
x1:
	.zero	4
	.globl	K
	.align 4
	.type	K, @object
	.size	K, 4
K:
	.zero	4
	.globl	W
	.align 4
	.type	W, @object
	.size	W, 4
W:
	.zero	4
	.globl	H
	.align 4
	.type	H, @object
	.size	H, 4
H:
	.zero	4
	.globl	buffer2
	.align 32
	.type	buffer2, @object
	.size	buffer2, 4938268
buffer2:
	.zero	4938268
	.globl	buffer
	.align 32
	.type	buffer, @object
	.size	buffer, 4567890
buffer:
	.zero	4567890
	.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>

char buffer[4567890];
int buffer2[1234567];

int H, W, K;
int x1, y1, x2, y2;
char* c[1234567];
int* cost[1234567];

int qs, qe;
int q[1234567][2];

int main(void) {
	int i;
	if (fgets(buffer, sizeof(buffer), stdin) == NULL) return 1;
	if (sscanf(buffer, "%d%d%d", &H, &W, &K) != 3) return 1;
	if (fgets(buffer, sizeof(buffer), stdin) == NULL) return 1;
	if (sscanf(buffer, "%d%d%d%d", &x1, &y1, &x2, &y2) != 4) return 1;
	for (i = 0; i < H; i++) {
		c[i] = &buffer[(W + 3) * i];
		cost[i] = &buffer2[W * i];
		if (fgets(c[i], W + 3, stdin) == NULL) return 1;
	}
	q[0][0] = x1 - 1;
	q[0][1] = y1 - 1;
	cost[x1 - 1][y1 - 1] = 1;
	qs = 0;
	qe = 1;
	while (qs < qe) {
		int cy = q[qs][0], cx = q[qs][1];
		int cc = cost[cy][cx];
		qs++;
		for (i = 1; i <= K && cx - i >= 0 && c[cy][cx - i] != '@' && (cost[cy][cx - i] == 0 || cost[cy][cx - i] > cc); i++) {
			if (cost[cy][cx - i] == 0) {
				q[qe][0] = cy;
				q[qe][1] = cx - i;
				qe++;
			}
			cost[cy][cx - i] = cc + 1;
		}
		for (i = 1; i <= K && cx + i < W && c[cy][cx + i] != '@' && (cost[cy][cx + i] == 0 || cost[cy][cx + i] > cc); i++) {
			if (cost[cy][cx + i] == 0) {
				q[qe][0] = cy;
				q[qe][1] = cx + i;
				qe++;
			}
			cost[cy][cx + i] = cc + 1;
		}
		for (i = 1; i <= K && cy - i >= 0 && c[cy - i][cx] != '@' && (cost[cy - i][cx] == 0 || cost[cy - i][cx] > cc); i++) {
			if (cost[cy - i][cx] == 0) {
				q[qe][0] = cy - i;
				q[qe][1] = cx;
				qe++;
			}
			cost[cy - i][cx] = cc + 1;
		}
		for (i = 1; i <= K && cy + i < H && c[cy + i][cx] != '@' && (cost[cy + i][cx] == 0 || cost[cy + i][cx] > cc); i++) {
			if (cost[cy + i][cx] == 0) {
				q[qe][0] = cy + i;
				q[qe][1] = cx;
				qe++;
			}
			cost[cy + i][cx] = cc + 1;
		}
	}
	printf("%d\n", cost[x2 - 1][y2 - 1] - 1);
	return 0;
}

2 3 1
2 1 2 3
.@.
.@.
.@.
 3 5 2
3 2 3 4
.....
.@-.@
..@..
 1 6 4
1 1 1 1
......
 3 5 4
3 2 3 4
.....
.@..@
..@..
 1 6 4
1 2 1 6
......
 3 5 4
3 2 1 4
.....
.@..@
..@..
 3 3 1
2 1 2 3
.@.
.@/
.@.
 3 3 0
2 1 2 3
.@.
.@.
.@.
 3 3 2
2 1 2 3
.@.
.@/
.@.
 3 3 0
2 2 2 3
.@.
.@.
.@.

-1
 5
 0
 4
 1
 3
 -1
 -1
 -1
 -1

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>

char buffer[4567890];
int buffer2[1234567];

int H, W, K;
int x1, y1, x2, y2;
char* c[1234567];
int* cost[1234567];

int qs, qe;
int q[1234567][2];

int main(void) {
	int i;
	if (fgets(buffer, sizeof(buffer), stdin) == NULL) return 1;
	if (sscanf(buffer, "%d%d%d", &H, &W, &K) != 3) return 1;
	if (fgets(buffer, sizeof(buffer), stdin) == NULL) return 1;
	if (sscanf(buffer, "%d%d%d%d", &x1, &y1, &x2, &y2) != 4) return 1;
	for (i = 0; i < H; i++) {
		c[i] = &buffer[(W + 3) * i];
		cost[i] = &buffer2[W * i];
		if (fgets(c[i], W + 3, stdin) == NULL) return 1;
	}
	q[0][0] = x1 - 1;
	q[0][1] = y1 - 1;
	cost[x1 - 1][y1 - 1] = 1;
	qs = 0;
	qe = 1;
	while (qs < qe) {
		int cy = q[qs][0], cx = q[qs][1];
		int cc = cost[cy][cx];
		qs++;
		for (i = 1; i <= K && cx - i >= 0 && c[cy][cx - i] != '@' && (cost[cy][cx - i] == 0 || cost[cy][cx - i] > cc); i++) {
			if (cost[cy][cx - i] == 0) {
				q[qe][0] = cy;
				q[qe][1] = cx - i;
				qe++;
			}
			cost[cy][cx - i] = cc + 1;
		}
		for (i = 1; i <= K && cx + i < W && c[cy][cx + i] != '@' && (cost[cy][cx + i] == 0 || cost[cy][cx + i] > cc); i++) {
			if (cost[cy][cx + i] == 0) {
				q[qe][0] = cy;
				q[qe][1] = cx + i;
				qe++;
			}
			cost[cy][cx + i] = cc + 1;
		}
		for (i = 1; i <= K && cy - i >= 0 && c[cy - i][cx] != '@' && (cost[cy - i][cx] == 0 || cost[cy - i][cx] > cc); i++) {
			if (cost[cy - i][cx] == 0) {
				q[qe][0] = cy - i;
				q[qe][1] = cx;
				qe++;
			}
			cost[cy - i][cx] = cc + 1;
		}
		for (i = 1; i <= K && cy + i < H && c[cy + i][cx] != '@' && (cost[cy + i][cx] == 0 || cost[cy + i][cx] > cc); i++) {
			if (cost[cy + i][cx] == 0) {
				q[qe][0] = cy + i;
				q[qe][1] = cx;
				qe++;
			}
			cost[cy + i][cx] = cc + 1;
		}
	}
	printf("%d\n", cost[x2 - 1][y2 - 1] - 1);
	return 0;
}
```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	buffer
	.bss
	.align 32
	.type	buffer, @object
	.size	buffer, 4567890
buffer:
	.zero	4567890
	.globl	buffer2
	.align 32
	.type	buffer2, @object
	.size	buffer2, 4938268
buffer2:
	.zero	4938268
	.globl	H
	.align 4
	.type	H, @object
	.size	H, 4
H:
	.zero	4
	.globl	W
	.align 4
	.type	W, @object
	.size	W, 4
W:
	.zero	4
	.globl	K
	.align 4
	.type	K, @object
	.size	K, 4
K:
	.zero	4
	.globl	x1
	.align 4
	.type	x1, @object
	.size	x1, 4
x1:
	.zero	4
	.globl	y1
	.align 4
	.type	y1, @object
	.size	y1, 4
y1:
	.zero	4
	.globl	x2
	.align 4
	.type	x2, @object
	.size	x2, 4
x2:
	.zero	4
	.globl	y2
	.align 4
	.type	y2, @object
	.size	y2, 4
y2:
	.zero	4
	.globl	c
	.align 32
	.type	c, @object
	.size	c, 9876536
c:
	.zero	9876536
	.globl	cost
	.align 32
	.type	cost, @object
	.size	cost, 9876536
cost:
	.zero	9876536
	.globl	qs
	.align 4
	.type	qs, @object
	.size	qs, 4
qs:
	.zero	4
	.globl	qe
	.align 4
	.type	qe, @object
	.size	qe, 4
qe:
	.zero	4
	.globl	q
	.align 32
	.type	q, @object
	.size	q, 9876536
q:
	.zero	9876536
	.section	.rodata
.LC0:
	.string	"%d%d%d"
.LC1:
	.string	"%d%d%d%d"
.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
	subq	$16, %rsp
	movq	stdin(%rip), %rax
	movq	%rax, %rdx
	movl	$4567890, %esi
	leaq	buffer(%rip), %rax
	movq	%rax, %rdi
	call	fgets@PLT
	testq	%rax, %rax
	jne	.L2
	movl	$1, %eax
	jmp	.L3
.L2:
	leaq	K(%rip), %r8
	leaq	W(%rip), %rax
	movq	%rax, %rcx
	leaq	H(%rip), %rax
	movq	%rax, %rdx
	leaq	.LC0(%rip), %rax
	movq	%rax, %rsi
	leaq	buffer(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_sscanf@PLT
	cmpl	$3, %eax
	je	.L4
	movl	$1, %eax
	jmp	.L3
.L4:
	movq	stdin(%rip), %rax
	movq	%rax, %rdx
	movl	$4567890, %esi
	leaq	buffer(%rip), %rax
	movq	%rax, %rdi
	call	fgets@PLT
	testq	%rax, %rax
	jne	.L5
	movl	$1, %eax
	jmp	.L3
.L5:
	leaq	y2(%rip), %r9
	leaq	x2(%rip), %r8
	leaq	y1(%rip), %rax
	movq	%rax, %rcx
	leaq	x1(%rip), %rax
	movq	%rax, %rdx
	leaq	.LC1(%rip), %rax
	movq	%rax, %rsi
	leaq	buffer(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_sscanf@PLT
	cmpl	$4, %eax
	je	.L6
	movl	$1, %eax
	jmp	.L3
.L6:
	movl	$0, -16(%rbp)
	jmp	.L7
.L9:
	movl	W(%rip), %eax
	addl	$3, %eax
	imull	-16(%rbp), %eax
	cltq
	leaq	buffer(%rip), %rdx
	leaq	(%rax,%rdx), %rcx
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	c(%rip), %rax
	movq	%rcx, (%rdx,%rax)
	movl	W(%rip), %eax
	imull	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	buffer2(%rip), %rax
	leaq	(%rdx,%rax), %rcx
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	cost(%rip), %rax
	movq	%rcx, (%rdx,%rax)
	movq	stdin(%rip), %rdx
	movl	W(%rip), %eax
	leal	3(%rax), %ecx
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rsi
	leaq	c(%rip), %rax
	movq	(%rsi,%rax), %rax
	movl	%ecx, %esi
	movq	%rax, %rdi
	call	fgets@PLT
	testq	%rax, %rax
	jne	.L8
	movl	$1, %eax
	jmp	.L3
.L8:
	addl	$1, -16(%rbp)
.L7:
	movl	H(%rip), %eax
	cmpl	%eax, -16(%rbp)
	jl	.L9
	movl	x1(%rip), %eax
	subl	$1, %eax
	movl	%eax, q(%rip)
	movl	y1(%rip), %eax
	subl	$1, %eax
	movl	%eax, 4+q(%rip)
	movl	x1(%rip), %eax
	subl	$1, %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	cost(%rip), %rax
	movq	(%rdx,%rax), %rdx
	movl	y1(%rip), %eax
	cltq
	salq	$2, %rax
	subq	$4, %rax
	addq	%rdx, %rax
	movl	$1, (%rax)
	movl	$0, qs(%rip)
	movl	$1, qe(%rip)
	jmp	.L10
.L26:
	movl	qs(%rip), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	q(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -12(%rbp)
	movl	qs(%rip), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	4+q(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -8(%rbp)
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	cost(%rip), %rax
	movq	(%rdx,%rax), %rdx
	movl	-8(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	movl	%eax, -4(%rbp)
	movl	qs(%rip), %eax
	addl	$1, %eax
	movl	%eax, qs(%rip)
	movl	$1, -16(%rbp)
	jmp	.L11
.L14:
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	cost(%rip), %rax
	movq	(%rdx,%rax), %rdx
	movl	-8(%rbp), %eax
	subl	-16(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	testl	%eax, %eax
	jne	.L12
	movl	qe(%rip), %eax
	cltq
	leaq	0(,%rax,8), %rcx
	leaq	q(%rip), %rdx
	movl	-12(%rbp), %eax
	movl	%eax, (%rcx,%rdx)
	movl	qe(%rip), %edx
	movl	-8(%rbp), %eax
	subl	-16(%rbp), %eax
	movslq	%edx, %rdx
	leaq	0(,%rdx,8), %rcx
	leaq	4+q(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	movl	qe(%rip), %eax
	addl	$1, %eax
	movl	%eax, qe(%rip)
.L12:
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	cost(%rip), %rax
	movq	(%rdx,%rax), %rdx
	movl	-8(%rbp), %eax
	subl	-16(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rdx, %rax
	movl	-4(%rbp), %edx
	addl	$1, %edx
	movl	%edx, (%rax)
	addl	$1, -16(%rbp)
.L11:
	movl	K(%rip), %eax
	cmpl	%eax, -16(%rbp)
	jg	.L13
	movl	-8(%rbp), %eax
	subl	-16(%rbp), %eax
	testl	%eax, %eax
	js	.L13
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	c(%rip), %rax
	movq	(%rdx,%rax), %rdx
	movl	-8(%rbp), %eax
	subl	-16(%rbp), %eax
	cltq
	addq	%rdx, %rax
	movzbl	(%rax), %eax
	cmpb	$64, %al
	je	.L13
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	cost(%rip), %rax
	movq	(%rdx,%rax), %rdx
	movl	-8(%rbp), %eax
	subl	-16(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	testl	%eax, %eax
	je	.L14
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	cost(%rip), %rax
	movq	(%rdx,%rax), %rdx
	movl	-8(%rbp), %eax
	subl	-16(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	cmpl	%eax, -4(%rbp)
	jl	.L14
.L13:
	movl	$1, -16(%rbp)
	jmp	.L15
.L18:
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	cost(%rip), %rax
	movq	(%rdx,%rax), %rdx
	movl	-8(%rbp), %ecx
	movl	-16(%rbp), %eax
	addl	%ecx, %eax
	cltq
	salq	$2, %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	testl	%eax, %eax
	jne	.L16
	movl	qe(%rip), %eax
	cltq
	leaq	0(,%rax,8), %rcx
	leaq	q(%rip), %rdx
	movl	-12(%rbp), %eax
	movl	%eax, (%rcx,%rdx)
	movl	qe(%rip), %eax
	movl	-8(%rbp), %ecx
	movl	-16(%rbp), %edx
	addl	%edx, %ecx
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	4+q(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	movl	qe(%rip), %eax
	addl	$1, %eax
	movl	%eax, qe(%rip)
.L16:
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	cost(%rip), %rax
	movq	(%rdx,%rax), %rdx
	movl	-8(%rbp), %ecx
	movl	-16(%rbp), %eax
	addl	%ecx, %eax
	cltq
	salq	$2, %rax
	addq	%rdx, %rax
	movl	-4(%rbp), %edx
	addl	$1, %edx
	movl	%edx, (%rax)
	addl	$1, -16(%rbp)
.L15:
	movl	K(%rip), %eax
	cmpl	%eax, -16(%rbp)
	jg	.L17
	movl	-8(%rbp), %edx
	movl	-16(%rbp), %eax
	addl	%eax, %edx
	movl	W(%rip), %eax
	cmpl	%eax, %edx
	jge	.L17
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	c(%rip), %rax
	movq	(%rdx,%rax), %rdx
	movl	-8(%rbp), %ecx
	movl	-16(%rbp), %eax
	addl	%ecx, %eax
	cltq
	addq	%rdx, %rax
	movzbl	(%rax), %eax
	cmpb	$64, %al
	je	.L17
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	cost(%rip), %rax
	movq	(%rdx,%rax), %rdx
	movl	-8(%rbp), %ecx
	movl	-16(%rbp), %eax
	addl	%ecx, %eax
	cltq
	salq	$2, %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	testl	%eax, %eax
	je	.L18
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	cost(%rip), %rax
	movq	(%rdx,%rax), %rdx
	movl	-8(%rbp), %ecx
	movl	-16(%rbp), %eax
	addl	%ecx, %eax
	cltq
	salq	$2, %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	cmpl	%eax, -4(%rbp)
	jl	.L18
.L17:
	movl	$1, -16(%rbp)
	jmp	.L19
.L22:
	movl	-12(%rbp), %eax
	subl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	cost(%rip), %rax
	movq	(%rdx,%rax), %rdx
	movl	-8(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	testl	%eax, %eax
	jne	.L20
	movl	qe(%rip), %edx
	movl	-12(%rbp), %eax
	subl	-16(%rbp), %eax
	movslq	%edx, %rdx
	leaq	0(,%rdx,8), %rcx
	leaq	q(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	movl	qe(%rip), %eax
	cltq
	leaq	0(,%rax,8), %rcx
	leaq	4+q(%rip), %rdx
	movl	-8(%rbp), %eax
	movl	%eax, (%rcx,%rdx)
	movl	qe(%rip), %eax
	addl	$1, %eax
	movl	%eax, qe(%rip)
.L20:
	movl	-12(%rbp), %eax
	subl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	cost(%rip), %rax
	movq	(%rdx,%rax), %rdx
	movl	-8(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rdx, %rax
	movl	-4(%rbp), %edx
	addl	$1, %edx
	movl	%edx, (%rax)
	addl	$1, -16(%rbp)
.L19:
	movl	K(%rip), %eax
	cmpl	%eax, -16(%rbp)
	jg	.L21
	movl	-12(%rbp), %eax
	subl	-16(%rbp), %eax
	testl	%eax, %eax
	js	.L21
	movl	-12(%rbp), %eax
	subl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	c(%rip), %rax
	movq	(%rdx,%rax), %rdx
	movl	-8(%rbp), %eax
	cltq
	addq	%rdx, %rax
	movzbl	(%rax), %eax
	cmpb	$64, %al
	je	.L21
	movl	-12(%rbp), %eax
	subl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	cost(%rip), %rax
	movq	(%rdx,%rax), %rdx
	movl	-8(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	testl	%eax, %eax
	je	.L22
	movl	-12(%rbp), %eax
	subl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	cost(%rip), %rax
	movq	(%rdx,%rax), %rdx
	movl	-8(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	cmpl	%eax, -4(%rbp)
	jl	.L22
.L21:
	movl	$1, -16(%rbp)
	jmp	.L23
.L25:
	movl	-12(%rbp), %edx
	movl	-16(%rbp), %eax
	addl	%edx, %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	cost(%rip), %rax
	movq	(%rdx,%rax), %rdx
	movl	-8(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	testl	%eax, %eax
	jne	.L24
	movl	qe(%rip), %eax
	movl	-12(%rbp), %ecx
	movl	-16(%rbp), %edx
	addl	%edx, %ecx
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	q(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	movl	qe(%rip), %eax
	cltq
	leaq	0(,%rax,8), %rcx
	leaq	4+q(%rip), %rdx
	movl	-8(%rbp), %eax
	movl	%eax, (%rcx,%rdx)
	movl	qe(%rip), %eax
	addl	$1, %eax
	movl	%eax, qe(%rip)
.L24:
	movl	-12(%rbp), %edx
	movl	-16(%rbp), %eax
	addl	%edx, %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	cost(%rip), %rax
	movq	(%rdx,%rax), %rdx
	movl	-8(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rdx, %rax
	movl	-4(%rbp), %edx
	addl	$1, %edx
	movl	%edx, (%rax)
	addl	$1, -16(%rbp)
.L23:
	movl	K(%rip), %eax
	cmpl	%eax, -16(%rbp)
	jg	.L10
	movl	-12(%rbp), %edx
	movl	-16(%rbp), %eax
	addl	%eax, %edx
	movl	H(%rip), %eax
	cmpl	%eax, %edx
	jge	.L10
	movl	-12(%rbp), %edx
	movl	-16(%rbp), %eax
	addl	%edx, %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	c(%rip), %rax
	movq	(%rdx,%rax), %rdx
	movl	-8(%rbp), %eax
	cltq
	addq	%rdx, %rax
	movzbl	(%rax), %eax
	cmpb	$64, %al
	je	.L10
	movl	-12(%rbp), %edx
	movl	-16(%rbp), %eax
	addl	%edx, %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	cost(%rip), %rax
	movq	(%rdx,%rax), %rdx
	movl	-8(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	testl	%eax, %eax
	je	.L25
	movl	-12(%rbp), %edx
	movl	-16(%rbp), %eax
	addl	%edx, %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	cost(%rip), %rax
	movq	(%rdx,%rax), %rdx
	movl	-8(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	cmpl	%eax, -4(%rbp)
	jl	.L25
.L10:
	movl	qs(%rip), %edx
	movl	qe(%rip), %eax
	cmpl	%eax, %edx
	jl	.L26
	movl	x2(%rip), %eax
	subl	$1, %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	cost(%rip), %rax
	movq	(%rdx,%rax), %rdx
	movl	y2(%rip), %eax
	cltq
	salq	$2, %rax
	subq	$4, %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	subl	$1, %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
.L3:
	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
	.globl	buffer
	.bss
	.align 32
	.type	buffer, @object
	.size	buffer, 4567890
buffer:
	.zero	4567890
	.globl	buffer2
	.align 32
	.type	buffer2, @object
	.size	buffer2, 4938268
buffer2:
	.zero	4938268
	.globl	H
	.align 4
	.type	H, @object
	.size	H, 4
H:
	.zero	4
	.globl	W
	.align 4
	.type	W, @object
	.size	W, 4
W:
	.zero	4
	.globl	K
	.align 4
	.type	K, @object
	.size	K, 4
K:
	.zero	4
	.globl	x1
	.align 4
	.type	x1, @object
	.size	x1, 4
x1:
	.zero	4
	.globl	y1
	.align 4
	.type	y1, @object
	.size	y1, 4
y1:
	.zero	4
	.globl	x2
	.align 4
	.type	x2, @object
	.size	x2, 4
x2:
	.zero	4
	.globl	y2
	.align 4
	.type	y2, @object
	.size	y2, 4
y2:
	.zero	4
	.globl	c
	.align 32
	.type	c, @object
	.size	c, 9876536
c:
	.zero	9876536
	.globl	cost
	.align 32
	.type	cost, @object
	.size	cost, 9876536
cost:
	.zero	9876536
	.globl	qs
	.align 4
	.type	qs, @object
	.size	qs, 4
qs:
	.zero	4
	.globl	qe
	.align 4
	.type	qe, @object
	.size	qe, 4
qe:
	.zero	4
	.globl	q
	.align 32
	.type	q, @object
	.size	q, 9876536
q:
	.zero	9876536
	.section	.rodata
.LC0:
	.string	"%d%d%d"
.LC1:
	.string	"%d%d%d%d"
.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
	subq	$16, %rsp
	movq	stdin(%rip), %rax
	movq	%rax, %rdx
	movl	$4567890, %esi
	leaq	buffer(%rip), %rax
	movq	%rax, %rdi
	call	fgets@PLT
	testq	%rax, %rax
	jne	.L2
	movl	$1, %eax
	jmp	.L3
.L2:
	leaq	K(%rip), %r8
	leaq	W(%rip), %rax
	movq	%rax, %rcx
	leaq	H(%rip), %rax
	movq	%rax, %rdx
	leaq	.LC0(%rip), %rax
	movq	%rax, %rsi
	leaq	buffer(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_sscanf@PLT
	cmpl	$3, %eax
	je	.L4
	movl	$1, %eax
	jmp	.L3
.L4:
	movq	stdin(%rip), %rax
	movq	%rax, %rdx
	movl	$4567890, %esi
	leaq	buffer(%rip), %rax
	movq	%rax, %rdi
	call	fgets@PLT
	testq	%rax, %rax
	jne	.L5
	movl	$1, %eax
	jmp	.L3
.L5:
	leaq	y2(%rip), %r9
	leaq	x2(%rip), %r8
	leaq	y1(%rip), %rax
	movq	%rax, %rcx
	leaq	x1(%rip), %rax
	movq	%rax, %rdx
	leaq	.LC1(%rip), %rax
	movq	%rax, %rsi
	leaq	buffer(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_sscanf@PLT
	cmpl	$4, %eax
	je	.L6
	movl	$1, %eax
	jmp	.L3
.L6:
	movl	$0, -16(%rbp)
	jmp	.L7
.L9:
	movl	W(%rip), %eax
	addl	$3, %eax
	imull	-16(%rbp), %eax
	cltq
	leaq	buffer(%rip), %rdx
	leaq	(%rax,%rdx), %rcx
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	c(%rip), %rax
	movq	%rcx, (%rdx,%rax)
	movl	W(%rip), %eax
	imull	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	buffer2(%rip), %rax
	leaq	(%rdx,%rax), %rcx
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	cost(%rip), %rax
	movq	%rcx, (%rdx,%rax)
	movq	stdin(%rip), %rdx
	movl	W(%rip), %eax
	leal	3(%rax), %ecx
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rsi
	leaq	c(%rip), %rax
	movq	(%rsi,%rax), %rax
	movl	%ecx, %esi
	movq	%rax, %rdi
	call	fgets@PLT
	testq	%rax, %rax
	jne	.L8
	movl	$1, %eax
	jmp	.L3
.L8:
	addl	$1, -16(%rbp)
.L7:
	movl	H(%rip), %eax
	cmpl	%eax, -16(%rbp)
	jl	.L9
	movl	x1(%rip), %eax
	subl	$1, %eax
	movl	%eax, q(%rip)
	movl	y1(%rip), %eax
	subl	$1, %eax
	movl	%eax, 4+q(%rip)
	movl	x1(%rip), %eax
	subl	$1, %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	cost(%rip), %rax
	movq	(%rdx,%rax), %rdx
	movl	y1(%rip), %eax
	cltq
	salq	$2, %rax
	subq	$4, %rax
	addq	%rdx, %rax
	movl	$1, (%rax)
	movl	$0, qs(%rip)
	movl	$1, qe(%rip)
	jmp	.L10
.L26:
	movl	qs(%rip), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	q(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -12(%rbp)
	movl	qs(%rip), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	4+q(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -8(%rbp)
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	cost(%rip), %rax
	movq	(%rdx,%rax), %rdx
	movl	-8(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	movl	%eax, -4(%rbp)
	movl	qs(%rip), %eax
	addl	$1, %eax
	movl	%eax, qs(%rip)
	movl	$1, -16(%rbp)
	jmp	.L11
.L14:
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	cost(%rip), %rax
	movq	(%rdx,%rax), %rdx
	movl	-8(%rbp), %eax
	subl	-16(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	testl	%eax, %eax
	jne	.L12
	movl	qe(%rip), %eax
	cltq
	leaq	0(,%rax,8), %rcx
	leaq	q(%rip), %rdx
	movl	-12(%rbp), %eax
	movl	%eax, (%rcx,%rdx)
	movl	qe(%rip), %edx
	movl	-8(%rbp), %eax
	subl	-16(%rbp), %eax
	movslq	%edx, %rdx
	leaq	0(,%rdx,8), %rcx
	leaq	4+q(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	movl	qe(%rip), %eax
	addl	$1, %eax
	movl	%eax, qe(%rip)
.L12:
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	cost(%rip), %rax
	movq	(%rdx,%rax), %rdx
	movl	-8(%rbp), %eax
	subl	-16(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rdx, %rax
	movl	-4(%rbp), %edx
	addl	$1, %edx
	movl	%edx, (%rax)
	addl	$1, -16(%rbp)
.L11:
	movl	K(%rip), %eax
	cmpl	%eax, -16(%rbp)
	jg	.L13
	movl	-8(%rbp), %eax
	subl	-16(%rbp), %eax
	testl	%eax, %eax
	js	.L13
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	c(%rip), %rax
	movq	(%rdx,%rax), %rdx
	movl	-8(%rbp), %eax
	subl	-16(%rbp), %eax
	cltq
	addq	%rdx, %rax
	movzbl	(%rax), %eax
	cmpb	$64, %al
	je	.L13
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	cost(%rip), %rax
	movq	(%rdx,%rax), %rdx
	movl	-8(%rbp), %eax
	subl	-16(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	testl	%eax, %eax
	je	.L14
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	cost(%rip), %rax
	movq	(%rdx,%rax), %rdx
	movl	-8(%rbp), %eax
	subl	-16(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	cmpl	%eax, -4(%rbp)
	jl	.L14
.L13:
	movl	$1, -16(%rbp)
	jmp	.L15
.L18:
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	cost(%rip), %rax
	movq	(%rdx,%rax), %rdx
	movl	-8(%rbp), %ecx
	movl	-16(%rbp), %eax
	addl	%ecx, %eax
	cltq
	salq	$2, %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	testl	%eax, %eax
	jne	.L16
	movl	qe(%rip), %eax
	cltq
	leaq	0(,%rax,8), %rcx
	leaq	q(%rip), %rdx
	movl	-12(%rbp), %eax
	movl	%eax, (%rcx,%rdx)
	movl	qe(%rip), %eax
	movl	-8(%rbp), %ecx
	movl	-16(%rbp), %edx
	addl	%edx, %ecx
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	4+q(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	movl	qe(%rip), %eax
	addl	$1, %eax
	movl	%eax, qe(%rip)
.L16:
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	cost(%rip), %rax
	movq	(%rdx,%rax), %rdx
	movl	-8(%rbp), %ecx
	movl	-16(%rbp), %eax
	addl	%ecx, %eax
	cltq
	salq	$2, %rax
	addq	%rdx, %rax
	movl	-4(%rbp), %edx
	addl	$1, %edx
	movl	%edx, (%rax)
	addl	$1, -16(%rbp)
.L15:
	movl	K(%rip), %eax
	cmpl	%eax, -16(%rbp)
	jg	.L17
	movl	-8(%rbp), %edx
	movl	-16(%rbp), %eax
	addl	%eax, %edx
	movl	W(%rip), %eax
	cmpl	%eax, %edx
	jge	.L17
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	c(%rip), %rax
	movq	(%rdx,%rax), %rdx
	movl	-8(%rbp), %ecx
	movl	-16(%rbp), %eax
	addl	%ecx, %eax
	cltq
	addq	%rdx, %rax
	movzbl	(%rax), %eax
	cmpb	$64, %al
	je	.L17
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	cost(%rip), %rax
	movq	(%rdx,%rax), %rdx
	movl	-8(%rbp), %ecx
	movl	-16(%rbp), %eax
	addl	%ecx, %eax
	cltq
	salq	$2, %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	testl	%eax, %eax
	je	.L18
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	cost(%rip), %rax
	movq	(%rdx,%rax), %rdx
	movl	-8(%rbp), %ecx
	movl	-16(%rbp), %eax
	addl	%ecx, %eax
	cltq
	salq	$2, %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	cmpl	%eax, -4(%rbp)
	jl	.L18
.L17:
	movl	$1, -16(%rbp)
	jmp	.L19
.L22:
	movl	-12(%rbp), %eax
	subl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	cost(%rip), %rax
	movq	(%rdx,%rax), %rdx
	movl	-8(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	testl	%eax, %eax
	jne	.L20
	movl	qe(%rip), %edx
	movl	-12(%rbp), %eax
	subl	-16(%rbp), %eax
	movslq	%edx, %rdx
	leaq	0(,%rdx,8), %rcx
	leaq	q(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	movl	qe(%rip), %eax
	cltq
	leaq	0(,%rax,8), %rcx
	leaq	4+q(%rip), %rdx
	movl	-8(%rbp), %eax
	movl	%eax, (%rcx,%rdx)
	movl	qe(%rip), %eax
	addl	$1, %eax
	movl	%eax, qe(%rip)
.L20:
	movl	-12(%rbp), %eax
	subl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	cost(%rip), %rax
	movq	(%rdx,%rax), %rdx
	movl	-8(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rdx, %rax
	movl	-4(%rbp), %edx
	addl	$1, %edx
	movl	%edx, (%rax)
	addl	$1, -16(%rbp)
.L19:
	movl	K(%rip), %eax
	cmpl	%eax, -16(%rbp)
	jg	.L21
	movl	-12(%rbp), %eax
	subl	-16(%rbp), %eax
	testl	%eax, %eax
	js	.L21
	movl	-12(%rbp), %eax
	subl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	c(%rip), %rax
	movq	(%rdx,%rax), %rdx
	movl	-8(%rbp), %eax
	cltq
	addq	%rdx, %rax
	movzbl	(%rax), %eax
	cmpb	$64, %al
	je	.L21
	movl	-12(%rbp), %eax
	subl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	cost(%rip), %rax
	movq	(%rdx,%rax), %rdx
	movl	-8(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	testl	%eax, %eax
	je	.L22
	movl	-12(%rbp), %eax
	subl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	cost(%rip), %rax
	movq	(%rdx,%rax), %rdx
	movl	-8(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	cmpl	%eax, -4(%rbp)
	jl	.L22
.L21:
	movl	$1, -16(%rbp)
	jmp	.L23
.L25:
	movl	-12(%rbp), %edx
	movl	-16(%rbp), %eax
	addl	%edx, %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	cost(%rip), %rax
	movq	(%rdx,%rax), %rdx
	movl	-8(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	testl	%eax, %eax
	jne	.L24
	movl	qe(%rip), %eax
	movl	-12(%rbp), %ecx
	movl	-16(%rbp), %edx
	addl	%edx, %ecx
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	q(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	movl	qe(%rip), %eax
	cltq
	leaq	0(,%rax,8), %rcx
	leaq	4+q(%rip), %rdx
	movl	-8(%rbp), %eax
	movl	%eax, (%rcx,%rdx)
	movl	qe(%rip), %eax
	addl	$1, %eax
	movl	%eax, qe(%rip)
.L24:
	movl	-12(%rbp), %edx
	movl	-16(%rbp), %eax
	addl	%edx, %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	cost(%rip), %rax
	movq	(%rdx,%rax), %rdx
	movl	-8(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rdx, %rax
	movl	-4(%rbp), %edx
	addl	$1, %edx
	movl	%edx, (%rax)
	addl	$1, -16(%rbp)
.L23:
	movl	K(%rip), %eax
	cmpl	%eax, -16(%rbp)
	jg	.L10
	movl	-12(%rbp), %edx
	movl	-16(%rbp), %eax
	addl	%eax, %edx
	movl	H(%rip), %eax
	cmpl	%eax, %edx
	jge	.L10
	movl	-12(%rbp), %edx
	movl	-16(%rbp), %eax
	addl	%edx, %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	c(%rip), %rax
	movq	(%rdx,%rax), %rdx
	movl	-8(%rbp), %eax
	cltq
	addq	%rdx, %rax
	movzbl	(%rax), %eax
	cmpb	$64, %al
	je	.L10
	movl	-12(%rbp), %edx
	movl	-16(%rbp), %eax
	addl	%edx, %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	cost(%rip), %rax
	movq	(%rdx,%rax), %rdx
	movl	-8(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	testl	%eax, %eax
	je	.L25
	movl	-12(%rbp), %edx
	movl	-16(%rbp), %eax
	addl	%edx, %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	cost(%rip), %rax
	movq	(%rdx,%rax), %rdx
	movl	-8(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	cmpl	%eax, -4(%rbp)
	jl	.L25
.L10:
	movl	qs(%rip), %edx
	movl	qe(%rip), %eax
	cmpl	%eax, %edx
	jl	.L26
	movl	x2(%rip), %eax
	subl	$1, %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	cost(%rip), %rax
	movq	(%rdx,%rax), %rdx
	movl	y2(%rip), %eax
	cltq
	salq	$2, %rax
	subq	$4, %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	subl	$1, %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
.L3:
	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:
