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>
#include <stdlib.h>
int h, w, d;
int xs[90001];
int ys[90001];
int ds[90001];
int s[90001];

int main() {
  int q;
  scanf("%d%d%d", &h, &w, &d);
  for (int y = 0; y < h; y++) {
    for (int x = 0; x < w; x++) {
      int v;
      scanf("%d", &v);
      xs[v] = x;
      ys[v] = y;
    }
  }
  for (int l0 = h * w - d, r0 = h * w; l0; l0--, r0--) {
    ds[l0] = abs(xs[r0] - xs[l0]) + abs(ys[r0] - ys[l0]);
  }
  for (int l = 0; l < d; l++) {
    s[l] = 0;
    for (int r = l + d; r <= h * w; r += d) {
      s[r] = s[r - d] + ds[r - d];
    }
  }
  scanf("%d", &q);
  for (int _ = 0; _ < q; _++) {
    int l, r;
    scanf("%d%d", &l, &r);
    int ans = s[r] - s[l];
    printf("%d\n", ans);
  }
  return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	h
	.bss
	.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	d
	.align 4
	.type	d, @object
	.size	d, 4
d:
	.zero	4
	.globl	xs
	.align 32
	.type	xs, @object
	.size	xs, 360004
xs:
	.zero	360004
	.globl	ys
	.align 32
	.type	ys, @object
	.size	ys, 360004
ys:
	.zero	360004
	.globl	ds
	.align 32
	.type	ds, @object
	.size	ds, 360004
ds:
	.zero	360004
	.globl	s
	.align 32
	.type	s, @object
	.size	s, 360004
s:
	.zero	360004
	.section	.rodata
.LC0:
	.string	"%d%d%d"
.LC1:
	.string	"%d"
.LC2:
	.string	"%d%d"
.LC3:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB6:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$64, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	d(%rip), %rax
	movq	%rax, %rcx
	leaq	w(%rip), %rax
	movq	%rax, %rdx
	leaq	h(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -40(%rbp)
	jmp	.L2
.L5:
	movl	$0, -36(%rbp)
	jmp	.L3
.L4:
	leaq	-44(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-44(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	xs(%rip), %rdx
	movl	-36(%rbp), %eax
	movl	%eax, (%rcx,%rdx)
	movl	-44(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	ys(%rip), %rdx
	movl	-40(%rbp), %eax
	movl	%eax, (%rcx,%rdx)
	addl	$1, -36(%rbp)
.L3:
	movl	w(%rip), %eax
	cmpl	%eax, -36(%rbp)
	jl	.L4
	addl	$1, -40(%rbp)
.L2:
	movl	h(%rip), %eax
	cmpl	%eax, -40(%rbp)
	jl	.L5
	movl	h(%rip), %edx
	movl	w(%rip), %eax
	imull	%edx, %eax
	movl	d(%rip), %edx
	subl	%edx, %eax
	movl	%eax, -32(%rbp)
	movl	h(%rip), %edx
	movl	w(%rip), %eax
	imull	%edx, %eax
	movl	%eax, -28(%rbp)
	jmp	.L6
.L7:
	movl	-28(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	xs(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	-32(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	xs(%rip), %rdx
	movl	(%rcx,%rdx), %edx
	subl	%edx, %eax
	movl	%eax, %edx
	negl	%edx
	cmovns	%edx, %eax
	movl	%eax, %esi
	movl	-28(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	ys(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	-32(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	ys(%rip), %rdx
	movl	(%rcx,%rdx), %edx
	subl	%edx, %eax
	movl	%eax, %edx
	negl	%edx
	cmovns	%edx, %eax
	leal	(%rsi,%rax), %ecx
	movl	-32(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	ds(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	subl	$1, -32(%rbp)
	subl	$1, -28(%rbp)
.L6:
	cmpl	$0, -32(%rbp)
	jne	.L7
	movl	$0, -24(%rbp)
	jmp	.L8
.L11:
	movl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	s(%rip), %rax
	movl	$0, (%rdx,%rax)
	movl	d(%rip), %edx
	movl	-24(%rbp), %eax
	addl	%edx, %eax
	movl	%eax, -20(%rbp)
	jmp	.L9
.L10:
	movl	d(%rip), %edx
	movl	-20(%rbp), %eax
	subl	%edx, %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	s(%rip), %rax
	movl	(%rdx,%rax), %ecx
	movl	d(%rip), %edx
	movl	-20(%rbp), %eax
	subl	%edx, %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	ds(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	%eax, %ecx
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	s(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	movl	d(%rip), %eax
	addl	%eax, -20(%rbp)
.L9:
	movl	h(%rip), %edx
	movl	w(%rip), %eax
	imull	%edx, %eax
	cmpl	%eax, -20(%rbp)
	jle	.L10
	addl	$1, -24(%rbp)
.L8:
	movl	d(%rip), %eax
	cmpl	%eax, -24(%rbp)
	jl	.L11
	leaq	-52(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -16(%rbp)
	jmp	.L12
.L13:
	leaq	-44(%rbp), %rdx
	leaq	-48(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-44(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	s(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	-48(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	s(%rip), %rdx
	movl	(%rcx,%rdx), %edx
	subl	%edx, %eax
	movl	%eax, -12(%rbp)
	movl	-12(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	addl	$1, -16(%rbp)
.L12:
	movl	-52(%rbp), %eax
	cmpl	%eax, -16(%rbp)
	jl	.L13
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L15
	call	__stack_chk_fail@PLT
.L15:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.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"
.LC2:
	.string	"%d%d"
.LC3:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB39:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	leaq	d(%rip), %rcx
	leaq	w(%rip), %rdx
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	leaq	h(%rip), %rsi
	leaq	.LC0(%rip), %rdi
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	leaq	.LC1(%rip), %r15
	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	$40, %rsp
	.cfi_def_cfa_offset 96
	movq	%fs:40, %rax
	movq	%rax, 24(%rsp)
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	h(%rip), %ecx
	movl	w(%rip), %eax
	testl	%ecx, %ecx
	jle	.L5
	xorl	%ebp, %ebp
	leaq	.LC1(%rip), %r15
	leaq	20(%rsp), %r14
	leaq	xs(%rip), %r13
	leaq	ys(%rip), %r12
	.p2align 4,,10
	.p2align 3
.L3:
	testl	%eax, %eax
	jle	.L5
	xorl	%ebx, %ebx
	.p2align 4,,10
	.p2align 3
.L4:
	movq	%r14, %rsi
	movq	%r15, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movslq	20(%rsp), %rax
	movl	%ebx, 0(%r13,%rax,4)
	addl	$1, %ebx
	movl	%ebp, (%r12,%rax,4)
	movl	w(%rip), %eax
	cmpl	%ebx, %eax
	jg	.L4
	movl	h(%rip), %ecx
	addl	$1, %ebp
	cmpl	%ebp, %ecx
	jg	.L3
.L5:
	imull	%eax, %ecx
	movl	d(%rip), %r10d
	movl	%ecx, %edx
	subl	%r10d, %edx
	je	.L13
	leal	-1(%rdx), %r8d
	movl	%edx, %r14d
	cmpl	$2, %r8d
	jbe	.L25
	movslq	%ecx, %rax
	movslq	%r10d, %rsi
	leaq	xs(%rip), %r11
	movl	%edx, %edi
	leaq	-12(,%rax,4), %r9
	shrl	$2, %edi
	subq	%rsi, %rax
	leaq	-12(,%rax,4), %r8
	negq	%rdi
	leaq	(%r11,%r9), %r13
	xorl	%eax, %eax
	leaq	ys(%rip), %rbx
	leaq	ds(%rip), %rsi
	salq	$4, %rdi
	leaq	(%r11,%r8), %r12
	leaq	(%rbx,%r8), %rbp
	addq	%rbx, %r9
	addq	%rsi, %r8
	.p2align 4,,10
	.p2align 3
.L11:
	movdqu	0(%r13,%rax), %xmm3
	movdqu	(%r12,%rax), %xmm4
	movdqu	(%r9,%rax), %xmm5
	movdqu	0(%rbp,%rax), %xmm6
	pshufd	$27, %xmm4, %xmm1
	pshufd	$27, %xmm3, %xmm0
	psubd	%xmm1, %xmm0
	pshufd	$27, %xmm6, %xmm2
	movdqa	%xmm0, %xmm1
	psrad	$31, %xmm1
	pxor	%xmm1, %xmm0
	psubd	%xmm1, %xmm0
	pshufd	$27, %xmm5, %xmm1
	psubd	%xmm2, %xmm1
	movdqa	%xmm1, %xmm2
	psrad	$31, %xmm2
	pxor	%xmm2, %xmm1
	psubd	%xmm2, %xmm1
	paddd	%xmm1, %xmm0
	pshufd	$27, %xmm0, %xmm0
	movups	%xmm0, (%r8,%rax)
	subq	$16, %rax
	cmpq	%rdi, %rax
	jne	.L11
	movl	%edx, %eax
	movl	%ecx, %edi
	andl	$-4, %eax
	subl	%eax, %edx
	subl	%eax, %edi
	leal	-1(%rdx), %r8d
	cmpl	%r14d, %eax
	je	.L13
.L10:
	movslq	%edx, %r9
	movslq	%edi, %r12
	movl	(%r11,%r12,4), %eax
	subl	(%r11,%r9,4), %eax
	movl	%eax, %ebp
	negl	%ebp
	cmovs	%eax, %ebp
	movl	(%rbx,%r12,4), %eax
	subl	(%rbx,%r9,4), %eax
	movl	%eax, %r12d
	negl	%r12d
	cmovns	%r12d, %eax
	addl	%ebp, %eax
	leal	-1(%rdi), %ebp
	movl	%eax, (%rsi,%r9,4)
	testl	%r8d, %r8d
	je	.L13
	movslq	%r8d, %r8
	movslq	%ebp, %rbp
	movl	(%r11,%rbp,4), %r9d
	subl	(%r11,%r8,4), %r9d
	movl	%r9d, %eax
	negl	%eax
	cmovs	%r9d, %eax
	movl	(%rbx,%rbp,4), %r9d
	subl	(%rbx,%r8,4), %r9d
	movl	%r9d, %ebp
	negl	%ebp
	cmovns	%ebp, %r9d
	subl	$2, %edi
	addl	%r9d, %eax
	movl	%eax, (%rsi,%r8,4)
	subl	$2, %edx
	je	.L13
	movslq	%edx, %rax
	movslq	%edi, %rdx
	movl	(%rbx,%rdx,4), %r8d
	subl	(%rbx,%rax,4), %r8d
	movl	%r8d, %edi
	movl	(%r11,%rdx,4), %edx
	negl	%edi
	cmovs	%r8d, %edi
	subl	(%r11,%rax,4), %edx
	movl	%edx, %r8d
	negl	%r8d
	cmovns	%r8d, %edx
	addl	%edi, %edx
	movl	%edx, (%rsi,%rax,4)
.L13:
	testl	%r10d, %r10d
	jle	.L9
	cmpl	$1, %r10d
	jne	.L45
	movl	$0, s(%rip)
	testl	%ecx, %ecx
	jle	.L9
	movslq	%ecx, %rcx
	xorl	%eax, %eax
	leaq	ds(%rip), %rsi
	xorl	%edx, %edx
	leaq	4+s(%rip), %rdi
	.p2align 4,,10
	.p2align 3
.L21:
	addl	(%rsi,%rax,4), %edx
	movl	%edx, (%rdi,%rax,4)
	addq	$1, %rax
	cmpq	%rcx, %rax
	jne	.L21
.L9:
	leaq	12(%rsp), %rsi
	movq	%r15, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	12(%rsp), %eax
	testl	%eax, %eax
	jle	.L16
	xorl	%r15d, %r15d
	leaq	20(%rsp), %r14
	leaq	s(%rip), %rbx
	leaq	16(%rsp), %r13
	leaq	.LC2(%rip), %r12
	leaq	.LC3(%rip), %rbp
	.p2align 4,,10
	.p2align 3
.L15:
	movq	%r14, %rdx
	movq	%r13, %rsi
	movq	%r12, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movslq	16(%rsp), %rax
	movslq	20(%rsp), %rdx
	movq	%rbp, %rsi
	movl	$1, %edi
	addl	$1, %r15d
	movl	(%rbx,%rdx,4), %edx
	subl	(%rbx,%rax,4), %edx
	xorl	%eax, %eax
	call	__printf_chk@PLT
	cmpl	%r15d, 12(%rsp)
	jg	.L15
.L16:
	movq	24(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L46
	addq	$40, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 56
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
.L45:
	.cfi_restore_state
	movslq	%r10d, %r9
	leal	(%r10,%r10), %r13d
	xorl	%r11d, %r11d
	imulq	$-4, %r9, %r12
	movq	%r9, %rbp
	leaq	s(%rip), %rbx
	leaq	ds(%rip), %rsi
	.p2align 4,,10
	.p2align 3
.L19:
	leaq	(%r11,%r12), %rdi
	movl	$0, (%rbx,%r11)
	movq	%rbp, %rax
	leaq	(%rbx,%rdi), %r8
	addq	%rsi, %rdi
	cmpl	%r10d, %ecx
	jl	.L22
	.p2align 4,,10
	.p2align 3
.L18:
	movl	(%rdi,%rax,4), %edx
	addl	(%r8,%rax,4), %edx
	movl	%edx, (%rbx,%rax,4)
	addq	%r9, %rax
	cmpl	%eax, %ecx
	jge	.L18
.L22:
	addl	$1, %r10d
	addq	$1, %rbp
	addq	$4, %r11
	subq	$4, %r12
	cmpl	%r13d, %r10d
	jne	.L19
	jmp	.L9
.L25:
	movl	%ecx, %edi
	leaq	xs(%rip), %r11
	leaq	ys(%rip), %rbx
	leaq	ds(%rip), %rsi
	jmp	.L10
.L46:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE39:
	.size	main, .-main
	.globl	s
	.bss
	.align 32
	.type	s, @object
	.size	s, 360004
s:
	.zero	360004
	.globl	ds
	.align 32
	.type	ds, @object
	.size	ds, 360004
ds:
	.zero	360004
	.globl	ys
	.align 32
	.type	ys, @object
	.size	ys, 360004
ys:
	.zero	360004
	.globl	xs
	.align 32
	.type	xs, @object
	.size	xs, 360004
xs:
	.zero	360004
	.globl	d
	.align 4
	.type	d, @object
	.size	d, 4
d:
	.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
	.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"
.LC2:
	.string	"%d%d"
.LC3:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB39:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	leaq	d(%rip), %rcx
	leaq	w(%rip), %rdx
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	leaq	h(%rip), %rsi
	leaq	.LC0(%rip), %rdi
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	leaq	.LC1(%rip), %r15
	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	$40, %rsp
	.cfi_def_cfa_offset 96
	movq	%fs:40, %rax
	movq	%rax, 24(%rsp)
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	h(%rip), %ecx
	movl	w(%rip), %eax
	testl	%ecx, %ecx
	jle	.L5
	xorl	%ebp, %ebp
	leaq	.LC1(%rip), %r15
	leaq	20(%rsp), %r14
	leaq	xs(%rip), %r13
	leaq	ys(%rip), %r12
	.p2align 4,,10
	.p2align 3
.L3:
	testl	%eax, %eax
	jle	.L5
	xorl	%ebx, %ebx
	.p2align 4,,10
	.p2align 3
.L4:
	movq	%r14, %rsi
	movq	%r15, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movslq	20(%rsp), %rax
	movl	%ebx, 0(%r13,%rax,4)
	addl	$1, %ebx
	movl	%ebp, (%r12,%rax,4)
	movl	w(%rip), %eax
	cmpl	%ebx, %eax
	jg	.L4
	movl	h(%rip), %ecx
	addl	$1, %ebp
	cmpl	%ebp, %ecx
	jg	.L3
.L5:
	imull	%eax, %ecx
	movl	d(%rip), %r10d
	movl	%ecx, %edx
	subl	%r10d, %edx
	je	.L13
	leal	-1(%rdx), %r8d
	movl	%edx, %r14d
	cmpl	$2, %r8d
	jbe	.L25
	movslq	%ecx, %rax
	movslq	%r10d, %rsi
	leaq	xs(%rip), %r11
	movl	%edx, %edi
	leaq	-12(,%rax,4), %r9
	shrl	$2, %edi
	subq	%rsi, %rax
	leaq	-12(,%rax,4), %r8
	negq	%rdi
	leaq	(%r11,%r9), %r13
	xorl	%eax, %eax
	leaq	ys(%rip), %rbx
	leaq	ds(%rip), %rsi
	salq	$4, %rdi
	leaq	(%r11,%r8), %r12
	leaq	(%rbx,%r8), %rbp
	addq	%rbx, %r9
	addq	%rsi, %r8
	.p2align 4,,10
	.p2align 3
.L11:
	movdqu	0(%r13,%rax), %xmm3
	movdqu	(%r12,%rax), %xmm4
	movdqu	(%r9,%rax), %xmm5
	movdqu	0(%rbp,%rax), %xmm6
	pshufd	$27, %xmm4, %xmm1
	pshufd	$27, %xmm3, %xmm0
	psubd	%xmm1, %xmm0
	pshufd	$27, %xmm6, %xmm2
	movdqa	%xmm0, %xmm1
	psrad	$31, %xmm1
	pxor	%xmm1, %xmm0
	psubd	%xmm1, %xmm0
	pshufd	$27, %xmm5, %xmm1
	psubd	%xmm2, %xmm1
	movdqa	%xmm1, %xmm2
	psrad	$31, %xmm2
	pxor	%xmm2, %xmm1
	psubd	%xmm2, %xmm1
	paddd	%xmm1, %xmm0
	pshufd	$27, %xmm0, %xmm0
	movups	%xmm0, (%r8,%rax)
	subq	$16, %rax
	cmpq	%rdi, %rax
	jne	.L11
	movl	%edx, %eax
	movl	%ecx, %edi
	andl	$-4, %eax
	subl	%eax, %edx
	subl	%eax, %edi
	leal	-1(%rdx), %r8d
	cmpl	%r14d, %eax
	je	.L13
.L10:
	movslq	%edx, %r9
	movslq	%edi, %r12
	movl	(%r11,%r12,4), %eax
	subl	(%r11,%r9,4), %eax
	movl	%eax, %ebp
	negl	%ebp
	cmovs	%eax, %ebp
	movl	(%rbx,%r12,4), %eax
	subl	(%rbx,%r9,4), %eax
	movl	%eax, %r12d
	negl	%r12d
	cmovns	%r12d, %eax
	addl	%ebp, %eax
	leal	-1(%rdi), %ebp
	movl	%eax, (%rsi,%r9,4)
	testl	%r8d, %r8d
	je	.L13
	movslq	%r8d, %r8
	movslq	%ebp, %rbp
	movl	(%r11,%rbp,4), %r9d
	subl	(%r11,%r8,4), %r9d
	movl	%r9d, %eax
	negl	%eax
	cmovs	%r9d, %eax
	movl	(%rbx,%rbp,4), %r9d
	subl	(%rbx,%r8,4), %r9d
	movl	%r9d, %ebp
	negl	%ebp
	cmovns	%ebp, %r9d
	subl	$2, %edi
	addl	%r9d, %eax
	movl	%eax, (%rsi,%r8,4)
	subl	$2, %edx
	je	.L13
	movslq	%edx, %rax
	movslq	%edi, %rdx
	movl	(%rbx,%rdx,4), %r8d
	subl	(%rbx,%rax,4), %r8d
	movl	%r8d, %edi
	movl	(%r11,%rdx,4), %edx
	negl	%edi
	cmovs	%r8d, %edi
	subl	(%r11,%rax,4), %edx
	movl	%edx, %r8d
	negl	%r8d
	cmovns	%r8d, %edx
	addl	%edi, %edx
	movl	%edx, (%rsi,%rax,4)
.L13:
	testl	%r10d, %r10d
	jle	.L9
	cmpl	$1, %r10d
	jne	.L45
	movl	$0, s(%rip)
	testl	%ecx, %ecx
	jle	.L9
	movslq	%ecx, %rcx
	xorl	%eax, %eax
	leaq	ds(%rip), %rsi
	xorl	%edx, %edx
	leaq	4+s(%rip), %rdi
	.p2align 4,,10
	.p2align 3
.L21:
	addl	(%rsi,%rax,4), %edx
	movl	%edx, (%rdi,%rax,4)
	addq	$1, %rax
	cmpq	%rcx, %rax
	jne	.L21
.L9:
	leaq	12(%rsp), %rsi
	movq	%r15, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	12(%rsp), %eax
	testl	%eax, %eax
	jle	.L16
	xorl	%r15d, %r15d
	leaq	20(%rsp), %r14
	leaq	s(%rip), %rbx
	leaq	16(%rsp), %r13
	leaq	.LC2(%rip), %r12
	leaq	.LC3(%rip), %rbp
	.p2align 4,,10
	.p2align 3
.L15:
	movq	%r14, %rdx
	movq	%r13, %rsi
	movq	%r12, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movslq	16(%rsp), %rax
	movslq	20(%rsp), %rdx
	movq	%rbp, %rsi
	movl	$1, %edi
	addl	$1, %r15d
	movl	(%rbx,%rdx,4), %edx
	subl	(%rbx,%rax,4), %edx
	xorl	%eax, %eax
	call	__printf_chk@PLT
	cmpl	%r15d, 12(%rsp)
	jg	.L15
.L16:
	movq	24(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L46
	addq	$40, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 56
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
.L45:
	.cfi_restore_state
	movslq	%r10d, %r9
	leal	(%r10,%r10), %r13d
	xorl	%r11d, %r11d
	imulq	$-4, %r9, %r12
	movq	%r9, %rbp
	leaq	s(%rip), %rbx
	leaq	ds(%rip), %rsi
	.p2align 4,,10
	.p2align 3
.L19:
	leaq	(%r11,%r12), %rdi
	movl	$0, (%rbx,%r11)
	movq	%rbp, %rax
	leaq	(%rbx,%rdi), %r8
	addq	%rsi, %rdi
	cmpl	%r10d, %ecx
	jl	.L22
	.p2align 4,,10
	.p2align 3
.L18:
	movl	(%rdi,%rax,4), %edx
	addl	(%r8,%rax,4), %edx
	movl	%edx, (%rbx,%rax,4)
	addq	%r9, %rax
	cmpl	%eax, %ecx
	jge	.L18
.L22:
	addl	$1, %r10d
	addq	$1, %rbp
	addq	$4, %r11
	subq	$4, %r12
	cmpl	%r13d, %r10d
	jne	.L19
	jmp	.L9
.L25:
	movl	%ecx, %edi
	leaq	xs(%rip), %r11
	leaq	ys(%rip), %rbx
	leaq	ds(%rip), %rsi
	jmp	.L10
.L46:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE39:
	.size	main, .-main
	.globl	s
	.bss
	.align 32
	.type	s, @object
	.size	s, 360004
s:
	.zero	360004
	.globl	ds
	.align 32
	.type	ds, @object
	.size	ds, 360004
ds:
	.zero	360004
	.globl	ys
	.align 32
	.type	ys, @object
	.size	ys, 360004
ys:
	.zero	360004
	.globl	xs
	.align 32
	.type	xs, @object
	.size	xs, 360004
xs:
	.zero	360004
	.globl	d
	.align 4
	.type	d, @object
	.size	d, 4
d:
	.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
	.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>
#include <stdlib.h>
int h, w, d;
int xs[90001];
int ys[90001];
int ds[90001];
int s[90001];

int main() {
  int q;
  scanf("%d%d%d", &h, &w, &d);
  for (int y = 0; y < h; y++) {
    for (int x = 0; x < w; x++) {
      int v;
      scanf("%d", &v);
      xs[v] = x;
      ys[v] = y;
    }
  }
  for (int l0 = h * w - d, r0 = h * w; l0; l0--, r0--) {
    ds[l0] = abs(xs[r0] - xs[l0]) + abs(ys[r0] - ys[l0]);
  }
  for (int l = 0; l < d; l++) {
    s[l] = 0;
    for (int r = l + d; r <= h * w; r += d) {
      s[r] = s[r - d] + ds[r - d];
    }
  }
  scanf("%d", &q);
  for (int _ = 0; _ < q; _++) {
    int l, r;
    scanf("%d%d", &l, &r);
    int ans = s[r] - s[l];
    printf("%d\n", ans);
  }
  return 0;
}
4 2 3
3 7
1 4
5 2
6 8
2
2 1
2 2
 5 5 4
13 25 7 15 17
16 22 20 2 9
14 11 12 1 19
10 6 23 8 18
3 21 5 24 4
1
13 13
2 10
13 13
 4 2 3
3 7
1 4
5 2
6 8
2
2 1
4 2
 3 3 1
1 4 3
2 5 7
8 9 6
1
4 8
 4 2 3
3 7
1 4
5 2
6 8
2
4 1
4 2
 3 3 1
1 4 3
2 5 7
8 9 6
1
4 9
 3 3 3
1 4 3
2 5 7
8 9 6
1
4 8
 3 3 2
1 4 3
2 5 7
8 9 6
1
4 1
 4 2 6
3 7
1 4
5 2
6 8
2
1 2
7 4
 5 5 4
13 25 7 15 17
16 22 20 2 9
14 11 12 1 19
10 6 23 8 18
3 21 5 24 4
3
13 13
0 10
13 13

0
0
 0
 0
-1
 7
 -1
-1
 8
 2
 -2
 0
-2
 0
5
0

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>
#include <stdlib.h>
int h, w, d;
int xs[90001];
int ys[90001];
int ds[90001];
int s[90001];

int main() {
  int q;
  scanf("%d%d%d", &h, &w, &d);
  for (int y = 0; y < h; y++) {
    for (int x = 0; x < w; x++) {
      int v;
      scanf("%d", &v);
      xs[v] = x;
      ys[v] = y;
    }
  }
  for (int l0 = h * w - d, r0 = h * w; l0; l0--, r0--) {
    ds[l0] = abs(xs[r0] - xs[l0]) + abs(ys[r0] - ys[l0]);
  }
  for (int l = 0; l < d; l++) {
    s[l] = 0;
    for (int r = l + d; r <= h * w; r += d) {
      s[r] = s[r - d] + ds[r - d];
    }
  }
  scanf("%d", &q);
  for (int _ = 0; _ < q; _++) {
    int l, r;
    scanf("%d%d", &l, &r);
    int ans = s[r] - s[l];
    printf("%d\n", ans);
  }
  return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	h
	.bss
	.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	d
	.align 4
	.type	d, @object
	.size	d, 4
d:
	.zero	4
	.globl	xs
	.align 32
	.type	xs, @object
	.size	xs, 360004
xs:
	.zero	360004
	.globl	ys
	.align 32
	.type	ys, @object
	.size	ys, 360004
ys:
	.zero	360004
	.globl	ds
	.align 32
	.type	ds, @object
	.size	ds, 360004
ds:
	.zero	360004
	.globl	s
	.align 32
	.type	s, @object
	.size	s, 360004
s:
	.zero	360004
	.section	.rodata
.LC0:
	.string	"%d%d%d"
.LC1:
	.string	"%d"
.LC2:
	.string	"%d%d"
.LC3:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB6:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$64, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	d(%rip), %rax
	movq	%rax, %rcx
	leaq	w(%rip), %rax
	movq	%rax, %rdx
	leaq	h(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -40(%rbp)
	jmp	.L2
.L5:
	movl	$0, -36(%rbp)
	jmp	.L3
.L4:
	leaq	-44(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-44(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	xs(%rip), %rdx
	movl	-36(%rbp), %eax
	movl	%eax, (%rcx,%rdx)
	movl	-44(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	ys(%rip), %rdx
	movl	-40(%rbp), %eax
	movl	%eax, (%rcx,%rdx)
	addl	$1, -36(%rbp)
.L3:
	movl	w(%rip), %eax
	cmpl	%eax, -36(%rbp)
	jl	.L4
	addl	$1, -40(%rbp)
.L2:
	movl	h(%rip), %eax
	cmpl	%eax, -40(%rbp)
	jl	.L5
	movl	h(%rip), %edx
	movl	w(%rip), %eax
	imull	%edx, %eax
	movl	d(%rip), %edx
	subl	%edx, %eax
	movl	%eax, -32(%rbp)
	movl	h(%rip), %edx
	movl	w(%rip), %eax
	imull	%edx, %eax
	movl	%eax, -28(%rbp)
	jmp	.L6
.L7:
	movl	-28(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	xs(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	-32(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	xs(%rip), %rdx
	movl	(%rcx,%rdx), %edx
	subl	%edx, %eax
	movl	%eax, %edx
	negl	%edx
	cmovns	%edx, %eax
	movl	%eax, %esi
	movl	-28(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	ys(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	-32(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	ys(%rip), %rdx
	movl	(%rcx,%rdx), %edx
	subl	%edx, %eax
	movl	%eax, %edx
	negl	%edx
	cmovns	%edx, %eax
	leal	(%rsi,%rax), %ecx
	movl	-32(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	ds(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	subl	$1, -32(%rbp)
	subl	$1, -28(%rbp)
.L6:
	cmpl	$0, -32(%rbp)
	jne	.L7
	movl	$0, -24(%rbp)
	jmp	.L8
.L11:
	movl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	s(%rip), %rax
	movl	$0, (%rdx,%rax)
	movl	d(%rip), %edx
	movl	-24(%rbp), %eax
	addl	%edx, %eax
	movl	%eax, -20(%rbp)
	jmp	.L9
.L10:
	movl	d(%rip), %edx
	movl	-20(%rbp), %eax
	subl	%edx, %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	s(%rip), %rax
	movl	(%rdx,%rax), %ecx
	movl	d(%rip), %edx
	movl	-20(%rbp), %eax
	subl	%edx, %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	ds(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	%eax, %ecx
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	s(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	movl	d(%rip), %eax
	addl	%eax, -20(%rbp)
.L9:
	movl	h(%rip), %edx
	movl	w(%rip), %eax
	imull	%edx, %eax
	cmpl	%eax, -20(%rbp)
	jle	.L10
	addl	$1, -24(%rbp)
.L8:
	movl	d(%rip), %eax
	cmpl	%eax, -24(%rbp)
	jl	.L11
	leaq	-52(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -16(%rbp)
	jmp	.L12
.L13:
	leaq	-44(%rbp), %rdx
	leaq	-48(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-44(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	s(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	-48(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	s(%rip), %rdx
	movl	(%rcx,%rdx), %edx
	subl	%edx, %eax
	movl	%eax, -12(%rbp)
	movl	-12(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	addl	$1, -16(%rbp)
.L12:
	movl	-52(%rbp), %eax
	cmpl	%eax, -16(%rbp)
	jl	.L13
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L15
	call	__stack_chk_fail@PLT
.L15:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.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	h
	.bss
	.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	d
	.align 4
	.type	d, @object
	.size	d, 4
d:
	.zero	4
	.globl	xs
	.align 32
	.type	xs, @object
	.size	xs, 360004
xs:
	.zero	360004
	.globl	ys
	.align 32
	.type	ys, @object
	.size	ys, 360004
ys:
	.zero	360004
	.globl	ds
	.align 32
	.type	ds, @object
	.size	ds, 360004
ds:
	.zero	360004
	.globl	s
	.align 32
	.type	s, @object
	.size	s, 360004
s:
	.zero	360004
	.section	.rodata
.LC0:
	.string	"%d%d%d"
.LC1:
	.string	"%d"
.LC2:
	.string	"%d%d"
.LC3:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB6:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$64, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	d(%rip), %rax
	movq	%rax, %rcx
	leaq	w(%rip), %rax
	movq	%rax, %rdx
	leaq	h(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -40(%rbp)
	jmp	.L2
.L5:
	movl	$0, -36(%rbp)
	jmp	.L3
.L4:
	leaq	-44(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-44(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	xs(%rip), %rdx
	movl	-36(%rbp), %eax
	movl	%eax, (%rcx,%rdx)
	movl	-44(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	ys(%rip), %rdx
	movl	-40(%rbp), %eax
	movl	%eax, (%rcx,%rdx)
	addl	$1, -36(%rbp)
.L3:
	movl	w(%rip), %eax
	cmpl	%eax, -36(%rbp)
	jl	.L4
	addl	$1, -40(%rbp)
.L2:
	movl	h(%rip), %eax
	cmpl	%eax, -40(%rbp)
	jl	.L5
	movl	h(%rip), %edx
	movl	w(%rip), %eax
	imull	%edx, %eax
	movl	d(%rip), %edx
	subl	%edx, %eax
	movl	%eax, -32(%rbp)
	movl	h(%rip), %edx
	movl	w(%rip), %eax
	imull	%edx, %eax
	movl	%eax, -28(%rbp)
	jmp	.L6
.L7:
	movl	-28(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	xs(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	-32(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	xs(%rip), %rdx
	movl	(%rcx,%rdx), %edx
	subl	%edx, %eax
	movl	%eax, %edx
	negl	%edx
	cmovns	%edx, %eax
	movl	%eax, %esi
	movl	-28(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	ys(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	-32(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	ys(%rip), %rdx
	movl	(%rcx,%rdx), %edx
	subl	%edx, %eax
	movl	%eax, %edx
	negl	%edx
	cmovns	%edx, %eax
	leal	(%rsi,%rax), %ecx
	movl	-32(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	ds(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	subl	$1, -32(%rbp)
	subl	$1, -28(%rbp)
.L6:
	cmpl	$0, -32(%rbp)
	jne	.L7
	movl	$0, -24(%rbp)
	jmp	.L8
.L11:
	movl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	s(%rip), %rax
	movl	$0, (%rdx,%rax)
	movl	d(%rip), %edx
	movl	-24(%rbp), %eax
	addl	%edx, %eax
	movl	%eax, -20(%rbp)
	jmp	.L9
.L10:
	movl	d(%rip), %edx
	movl	-20(%rbp), %eax
	subl	%edx, %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	s(%rip), %rax
	movl	(%rdx,%rax), %ecx
	movl	d(%rip), %edx
	movl	-20(%rbp), %eax
	subl	%edx, %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	ds(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	%eax, %ecx
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	s(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	movl	d(%rip), %eax
	addl	%eax, -20(%rbp)
.L9:
	movl	h(%rip), %edx
	movl	w(%rip), %eax
	imull	%edx, %eax
	cmpl	%eax, -20(%rbp)
	jle	.L10
	addl	$1, -24(%rbp)
.L8:
	movl	d(%rip), %eax
	cmpl	%eax, -24(%rbp)
	jl	.L11
	leaq	-52(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -16(%rbp)
	jmp	.L12
.L13:
	leaq	-44(%rbp), %rdx
	leaq	-48(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-44(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	s(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	-48(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	s(%rip), %rdx
	movl	(%rcx,%rdx), %edx
	subl	%edx, %eax
	movl	%eax, -12(%rbp)
	movl	-12(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	addl	$1, -16(%rbp)
.L12:
	movl	-52(%rbp), %eax
	cmpl	%eax, -16(%rbp)
	jl	.L13
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L15
	call	__stack_chk_fail@PLT
.L15:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.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:
