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

```c
//WA

#include <stdio.h>
//#include <stdlib.h>
//#include <string.h>
#include <limits.h>
//#include <math.h>

int main() {
  int n, c;
  scanf("%d%d", &n, &c);
  int d[c][c], g[n][n], cnt[3][c];
  for (int i=0; i<c; i++) for (int j=0; j<c; j++) scanf("%d", &(d[i][j]));
  for (int i=0; i<3; i++) for (int j=0; j<c; j++) cnt[i][j] = 0;
  for (int i=0; i<n; i++) for (int j=0; j<n; j++) {
    scanf("%d", &(g[i][j]));
    g[i][j]--;
    cnt[(i+j)%3][g[i][j]]++;
  }
  int ans = INT_MAX, sum;
  for (int i=0; i<c; i++) {
    for (int j=0; j<c; j++) {
      if (i == j) continue;
      for (int k=0; k<c; k++) {
        if (i == k || j == k) continue;
        sum = 0;
        for (int l=0; l<c; l++) sum += cnt[0][l]*d[l][i] + cnt[1][l]*d[l][j] + cnt[2][l]*d[l][k];
        ans = (ans < sum) ? ans : sum;
      }
    }
  }
  printf("%d\n", ans);
  return 0;
}
```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%d%d"
.LC1:
	.string	"%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
	pushq	%r15
	pushq	%r14
	pushq	%r13
	pushq	%r12
	pushq	%rbx
	subq	$328, %rsp
	.cfi_offset 15, -24
	.cfi_offset 14, -32
	.cfi_offset 13, -40
	.cfi_offset 12, -48
	.cfi_offset 3, -56
	movq	%fs:40, %rax
	movq	%rax, -56(%rbp)
	xorl	%eax, %eax
	movq	%rsp, %rax
	movq	%rax, -360(%rbp)
	leaq	-172(%rbp), %rdx
	leaq	-176(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-172(%rbp), %esi
	movl	-172(%rbp), %edi
	movslq	%esi, %rax
	subq	$1, %rax
	movq	%rax, -120(%rbp)
	movslq	%esi, %rax
	movq	%rax, -192(%rbp)
	movq	$0, -184(%rbp)
	movslq	%esi, %rax
	salq	$2, %rax
	movq	%rax, -192(%rbp)
	movslq	%edi, %rax
	subq	$1, %rax
	movq	%rax, -112(%rbp)
	movslq	%esi, %rax
	movq	%rax, %r14
	movl	$0, %r15d
	movslq	%edi, %rax
	movq	%rax, %r12
	movl	$0, %r13d
	movq	%r15, %rdx
	imulq	%r12, %rdx
	movq	%r13, %rax
	imulq	%r14, %rax
	leaq	(%rdx,%rax), %rcx
	movq	%r14, %rax
	mulq	%r12
	addq	%rdx, %rcx
	movq	%rcx, %rdx
	movslq	%esi, %rax
	movq	%rax, -208(%rbp)
	movq	$0, -200(%rbp)
	movslq	%edi, %rax
	movq	%rax, -224(%rbp)
	movq	$0, -216(%rbp)
	movq	-208(%rbp), %r9
	movq	-200(%rbp), %r10
	movq	%r10, %rdx
	movq	-224(%rbp), %r11
	movq	-216(%rbp), %r12
	imulq	%r11, %rdx
	movq	%r12, %rax
	imulq	%r9, %rax
	leaq	(%rdx,%rax), %rcx
	movq	%r9, %rax
	mulq	%r11
	addq	%rdx, %rcx
	movq	%rcx, %rdx
	movslq	%esi, %rdx
	movslq	%edi, %rax
	imulq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	movl	$16, %eax
	subq	$1, %rax
	addq	%rdx, %rax
	movl	$16, %ebx
	movl	$0, %edx
	divq	%rbx
	imulq	$16, %rax, %rdx
	movq	%rdx, %rax
	andq	$-4096, %rax
	movq	%rsp, %rcx
	subq	%rax, %rcx
.L2:
	cmpq	%rcx, %rsp
	je	.L3
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	jmp	.L2
.L3:
	movq	%rdx, %rax
	andl	$4095, %eax
	subq	%rax, %rsp
	movq	%rdx, %rax
	andl	$4095, %eax
	testq	%rax, %rax
	je	.L4
	movq	%rdx, %rax
	andl	$4095, %eax
	subq	$8, %rax
	addq	%rsp, %rax
	orq	$0, (%rax)
.L4:
	movq	%rsp, %rax
	addq	$3, %rax
	shrq	$2, %rax
	salq	$2, %rax
	movq	%rax, -104(%rbp)
	movl	-176(%rbp), %esi
	movl	-176(%rbp), %edi
	movslq	%esi, %rax
	subq	$1, %rax
	movq	%rax, -96(%rbp)
	movslq	%esi, %rax
	movq	%rax, -336(%rbp)
	movq	$0, -328(%rbp)
	movslq	%esi, %rax
	leaq	0(,%rax,4), %r12
	movslq	%edi, %rax
	subq	$1, %rax
	movq	%rax, -88(%rbp)
	movslq	%esi, %rax
	movq	%rax, -240(%rbp)
	movq	$0, -232(%rbp)
	movslq	%edi, %rax
	movq	%rax, -256(%rbp)
	movq	$0, -248(%rbp)
	movq	-240(%rbp), %r9
	movq	-232(%rbp), %r10
	movq	%r10, %rdx
	movq	-256(%rbp), %r14
	movq	-248(%rbp), %r15
	imulq	%r14, %rdx
	movq	%r15, %rax
	imulq	%r9, %rax
	leaq	(%rdx,%rax), %rcx
	movq	%r9, %rax
	mulq	%r14
	addq	%rdx, %rcx
	movq	%rcx, %rdx
	movslq	%esi, %rax
	movq	%rax, -272(%rbp)
	movq	$0, -264(%rbp)
	movslq	%edi, %rax
	movq	%rax, -288(%rbp)
	movq	$0, -280(%rbp)
	movq	-272(%rbp), %r9
	movq	-264(%rbp), %r10
	movq	%r10, %rdx
	movq	-288(%rbp), %r14
	movq	-280(%rbp), %r15
	imulq	%r14, %rdx
	movq	%r15, %rax
	imulq	%r9, %rax
	leaq	(%rdx,%rax), %rcx
	movq	%r9, %rax
	mulq	%r14
	addq	%rdx, %rcx
	movq	%rcx, %rdx
	movslq	%esi, %rdx
	movslq	%edi, %rax
	imulq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	movl	$16, %eax
	subq	$1, %rax
	addq	%rdx, %rax
	movl	$16, %ebx
	movl	$0, %edx
	divq	%rbx
	imulq	$16, %rax, %rax
	movq	%rax, %rcx
	andq	$-4096, %rcx
	movq	%rsp, %rdx
	subq	%rcx, %rdx
.L5:
	cmpq	%rdx, %rsp
	je	.L6
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	jmp	.L5
.L6:
	movq	%rax, %rdx
	andl	$4095, %edx
	subq	%rdx, %rsp
	movq	%rax, %rdx
	andl	$4095, %edx
	testq	%rdx, %rdx
	je	.L7
	andl	$4095, %eax
	subq	$8, %rax
	addq	%rsp, %rax
	orq	$0, (%rax)
.L7:
	movq	%rsp, %rax
	addq	$3, %rax
	shrq	$2, %rax
	salq	$2, %rax
	movq	%rax, -80(%rbp)
	movl	-172(%rbp), %ecx
	movslq	%ecx, %rax
	subq	$1, %rax
	movq	%rax, -72(%rbp)
	movslq	%ecx, %rax
	movq	%rax, -352(%rbp)
	movq	$0, -344(%rbp)
	movslq	%ecx, %rax
	leaq	0(,%rax,4), %rbx
	movslq	%ecx, %rax
	movq	%rax, -304(%rbp)
	movq	$0, -296(%rbp)
	movq	-304(%rbp), %r10
	movq	-296(%rbp), %r11
	imulq	$96, %r11, %rdx
	imulq	$0, %r10, %rax
	leaq	(%rdx,%rax), %rsi
	movl	$96, %eax
	mulq	%r10
	addq	%rdx, %rsi
	movq	%rsi, %rdx
	movslq	%ecx, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	movslq	%ecx, %rax
	movq	%rax, -320(%rbp)
	movq	$0, -312(%rbp)
	movq	-320(%rbp), %r8
	movq	-312(%rbp), %r9
	imulq	$96, %r9, %rdx
	imulq	$0, %r8, %rax
	leaq	(%rdx,%rax), %rsi
	movl	$96, %eax
	mulq	%r8
	addq	%rdx, %rsi
	movq	%rsi, %rdx
	movslq	%ecx, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	movq	%rax, %rdx
	movl	$16, %eax
	subq	$1, %rax
	addq	%rdx, %rax
	movl	$16, %edi
	movl	$0, %edx
	divq	%rdi
	imulq	$16, %rax, %rax
	movq	%rax, %rcx
	andq	$-4096, %rcx
	movq	%rsp, %rdx
	subq	%rcx, %rdx
.L8:
	cmpq	%rdx, %rsp
	je	.L9
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	jmp	.L8
.L9:
	movq	%rax, %rdx
	andl	$4095, %edx
	subq	%rdx, %rsp
	movq	%rax, %rdx
	andl	$4095, %edx
	testq	%rdx, %rdx
	je	.L10
	andl	$4095, %eax
	subq	$8, %rax
	addq	%rsp, %rax
	orq	$0, (%rax)
.L10:
	movq	%rsp, %rax
	addq	$3, %rax
	shrq	$2, %rax
	salq	$2, %rax
	movq	%rax, -64(%rbp)
	movl	$0, -168(%rbp)
	jmp	.L11
.L14:
	movl	$0, -164(%rbp)
	jmp	.L12
.L13:
	movq	-192(%rbp), %rdx
	shrq	$2, %rdx
	movl	-164(%rbp), %eax
	movslq	%eax, %rcx
	movl	-168(%rbp), %eax
	cltq
	imulq	%rdx, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rdx
	movq	-104(%rbp), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -164(%rbp)
.L12:
	movl	-172(%rbp), %eax
	cmpl	%eax, -164(%rbp)
	jl	.L13
	addl	$1, -168(%rbp)
.L11:
	movl	-172(%rbp), %eax
	cmpl	%eax, -168(%rbp)
	jl	.L14
	movl	$0, -160(%rbp)
	jmp	.L15
.L18:
	movl	$0, -156(%rbp)
	jmp	.L16
.L17:
	movq	%rbx, %rcx
	shrq	$2, %rcx
	movq	-64(%rbp), %rax
	movl	-156(%rbp), %edx
	movslq	%edx, %rsi
	movl	-160(%rbp), %edx
	movslq	%edx, %rdx
	imulq	%rcx, %rdx
	addq	%rsi, %rdx
	movl	$0, (%rax,%rdx,4)
	addl	$1, -156(%rbp)
.L16:
	movl	-172(%rbp), %eax
	cmpl	%eax, -156(%rbp)
	jl	.L17
	addl	$1, -160(%rbp)
.L15:
	cmpl	$2, -160(%rbp)
	jle	.L18
	movl	$0, -152(%rbp)
	jmp	.L19
.L22:
	movl	$0, -148(%rbp)
	jmp	.L20
.L21:
	movq	%r12, %rdx
	shrq	$2, %rdx
	movl	-148(%rbp), %eax
	movslq	%eax, %rcx
	movl	-152(%rbp), %eax
	cltq
	imulq	%rdx, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rdx
	movq	-80(%rbp), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movq	%r12, %rax
	shrq	$2, %rax
	movq	-80(%rbp), %rdx
	movl	-148(%rbp), %ecx
	movslq	%ecx, %rsi
	movl	-152(%rbp), %ecx
	movslq	%ecx, %rcx
	imulq	%rax, %rcx
	addq	%rsi, %rcx
	movl	(%rdx,%rcx,4), %edx
	leal	-1(%rdx), %ecx
	movq	-80(%rbp), %rdx
	movl	-148(%rbp), %esi
	movslq	%esi, %rdi
	movl	-152(%rbp), %esi
	movslq	%esi, %rsi
	imulq	%rsi, %rax
	addq	%rdi, %rax
	movl	%ecx, (%rdx,%rax,4)
	movq	%rbx, %rsi
	shrq	$2, %rsi
	movl	-152(%rbp), %edx
	movl	-148(%rbp), %eax
	addl	%eax, %edx
	movslq	%edx, %rax
	imulq	$1431655766, %rax, %rax
	shrq	$32, %rax
	movl	%edx, %ecx
	sarl	$31, %ecx
	subl	%ecx, %eax
	movl	%eax, %ecx
	addl	%ecx, %ecx
	addl	%eax, %ecx
	movl	%edx, %eax
	subl	%ecx, %eax
	movq	%r12, %rdi
	shrq	$2, %rdi
	movq	-80(%rbp), %rdx
	movl	-148(%rbp), %ecx
	movslq	%ecx, %r8
	movl	-152(%rbp), %ecx
	movslq	%ecx, %rcx
	imulq	%rdi, %rcx
	addq	%r8, %rcx
	movl	(%rdx,%rcx,4), %edx
	movq	-64(%rbp), %rcx
	movslq	%edx, %r8
	movslq	%eax, %rdi
	imulq	%rsi, %rdi
	addq	%r8, %rdi
	movl	(%rcx,%rdi,4), %ecx
	leal	1(%rcx), %edi
	movq	-64(%rbp), %rcx
	movslq	%edx, %rdx
	cltq
	imulq	%rsi, %rax
	addq	%rdx, %rax
	movl	%edi, (%rcx,%rax,4)
	addl	$1, -148(%rbp)
.L20:
	movl	-176(%rbp), %eax
	cmpl	%eax, -148(%rbp)
	jl	.L21
	addl	$1, -152(%rbp)
.L19:
	movl	-176(%rbp), %eax
	cmpl	%eax, -152(%rbp)
	jl	.L22
	movl	$2147483647, -144(%rbp)
	movl	$0, -136(%rbp)
	jmp	.L23
.L35:
	movl	$0, -132(%rbp)
	jmp	.L24
.L34:
	movl	-136(%rbp), %eax
	cmpl	-132(%rbp), %eax
	je	.L38
	movl	$0, -128(%rbp)
	jmp	.L27
.L33:
	movl	-136(%rbp), %eax
	cmpl	-128(%rbp), %eax
	je	.L39
	movl	-132(%rbp), %eax
	cmpl	-128(%rbp), %eax
	je	.L39
	movl	$0, -140(%rbp)
	movl	$0, -124(%rbp)
	jmp	.L31
.L32:
	movq	-64(%rbp), %rax
	movl	-124(%rbp), %edx
	movslq	%edx, %rdx
	movl	(%rax,%rdx,4), %edx
	movq	-192(%rbp), %r11
	movq	%r11, %rsi
	shrq	$2, %rsi
	movq	-104(%rbp), %rax
	movl	-136(%rbp), %ecx
	movslq	%ecx, %rdi
	movl	-124(%rbp), %ecx
	movslq	%ecx, %rcx
	imulq	%rsi, %rcx
	addq	%rdi, %rcx
	movl	(%rax,%rcx,4), %eax
	movl	%edx, %edi
	imull	%eax, %edi
	movq	%rbx, %rcx
	shrq	$2, %rcx
	movq	-64(%rbp), %rax
	movl	-124(%rbp), %edx
	movslq	%edx, %rdx
	addq	%rcx, %rdx
	movl	(%rax,%rdx,4), %edx
	movq	%r11, %rsi
	shrq	$2, %rsi
	movq	-104(%rbp), %rax
	movl	-132(%rbp), %ecx
	movslq	%ecx, %r8
	movl	-124(%rbp), %ecx
	movslq	%ecx, %rcx
	imulq	%rsi, %rcx
	addq	%r8, %rcx
	movl	(%rax,%rcx,4), %eax
	imull	%edx, %eax
	leal	(%rdi,%rax), %r8d
	movq	%rbx, %rcx
	shrq	$2, %rcx
	movq	-64(%rbp), %rax
	movl	-124(%rbp), %edx
	movslq	%edx, %rdx
	addq	%rcx, %rcx
	addq	%rcx, %rdx
	movl	(%rax,%rdx,4), %edx
	movq	%r11, %rsi
	shrq	$2, %rsi
	movq	-104(%rbp), %rax
	movl	-128(%rbp), %ecx
	movslq	%ecx, %rdi
	movl	-124(%rbp), %ecx
	movslq	%ecx, %rcx
	imulq	%rsi, %rcx
	addq	%rdi, %rcx
	movl	(%rax,%rcx,4), %eax
	imull	%edx, %eax
	addl	%r8d, %eax
	addl	%eax, -140(%rbp)
	addl	$1, -124(%rbp)
.L31:
	movl	-172(%rbp), %eax
	cmpl	%eax, -124(%rbp)
	jl	.L32
	movl	-144(%rbp), %edx
	movl	-140(%rbp), %eax
	cmpl	%eax, %edx
	cmovle	%edx, %eax
	movl	%eax, -144(%rbp)
	jmp	.L30
.L39:
	nop
.L30:
	addl	$1, -128(%rbp)
.L27:
	movl	-172(%rbp), %eax
	cmpl	%eax, -128(%rbp)
	jl	.L33
	jmp	.L26
.L38:
	nop
.L26:
	addl	$1, -132(%rbp)
.L24:
	movl	-172(%rbp), %eax
	cmpl	%eax, -132(%rbp)
	jl	.L34
	addl	$1, -136(%rbp)
.L23:
	movl	-172(%rbp), %eax
	cmpl	%eax, -136(%rbp)
	jl	.L35
	movl	-144(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	movq	-360(%rbp), %rsp
	movq	-56(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L37
	call	__stack_chk_fail@PLT
.L37:
	leaq	-40(%rbp), %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	main, .-main
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:
```

Only output the optimized assembly code. Do not include any other text. Do not write any comments in the assembly code. Wrap the assembly code in ```assembly``` tags.
user
	.file	"temp.c"
	.text
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d%d"
.LC1:
	.string	"%d"
.LC2:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB23:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	leaq	.LC0(%rip), %rdi
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	pushq	%r15
	pushq	%r14
	leaq	-60(%rbp), %rdx
	leaq	-64(%rbp), %rsi
	pushq	%r13
	pushq	%r12
	pushq	%rbx
	subq	$88, %rsp
	.cfi_offset 15, -24
	.cfi_offset 14, -32
	.cfi_offset 13, -40
	.cfi_offset 12, -48
	.cfi_offset 3, -56
	movq	%fs:40, %rax
	movq	%rax, -56(%rbp)
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movslq	-60(%rbp), %rax
	movq	%rsp, %rdi
	movq	%rax, %rdx
	leaq	0(,%rax,4), %rsi
	movq	%rax, %rcx
	imulq	%rax, %rdx
	movq	%rsi, -88(%rbp)
	leaq	15(,%rdx,4), %rsi
	movq	%rsi, %rdx
	andq	$-4096, %rsi
	subq	%rsi, %rdi
	andq	$-16, %rdx
	cmpq	%rdi, %rsp
	je	.L3
.L57:
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	cmpq	%rdi, %rsp
	jne	.L57
.L3:
	andl	$4095, %edx
	subq	%rdx, %rsp
	testq	%rdx, %rdx
	jne	.L58
.L4:
	movslq	-64(%rbp), %rdx
	movq	%rsp, %rdi
	movq	%rsp, %rbx
	leaq	0(,%rdx,4), %rsi
	imulq	%rdx, %rdx
	movq	%rsi, -104(%rbp)
	leaq	15(,%rdx,4), %rsi
	movq	%rsi, %rdx
	andq	$-4096, %rsi
	andq	$-16, %rdx
	subq	%rsi, %rdi
.L5:
	cmpq	%rdi, %rsp
	je	.L6
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	jmp	.L5
.L58:
	orq	$0, -8(%rsp,%rdx)
	jmp	.L4
.L6:
	andl	$4095, %edx
	subq	%rdx, %rsp
	testq	%rdx, %rdx
	jne	.L59
.L7:
	leaq	(%rax,%rax,2), %rax
	movq	%rsp, -96(%rbp)
	movq	%rsp, %rsi
	leaq	15(,%rax,4), %rdx
	movq	%rdx, %rax
	andq	$-4096, %rdx
	andq	$-16, %rax
	subq	%rdx, %rsi
.L8:
	cmpq	%rsi, %rsp
	je	.L9
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	jmp	.L8
.L59:
	orq	$0, -8(%rsp,%rdx)
	jmp	.L7
.L9:
	andl	$4095, %eax
	subq	%rax, %rsp
	testq	%rax, %rax
	je	.L10
	orq	$0, -8(%rsp,%rax)
.L10:
	movq	-88(%rbp), %r15
	movq	%rsp, %r12
	shrq	$2, %r15
	testl	%ecx, %ecx
	jle	.L16
	movq	%r15, -80(%rbp)
	xorl	%eax, %eax
	xorl	%r14d, %r14d
	leaq	.LC1(%rip), %r13
	movq	%rbx, -72(%rbp)
	movq	%r12, -112(%rbp)
	movq	%rax, %r12
.L12:
	movq	-72(%rbp), %rax
	xorl	%r15d, %r15d
	leaq	(%rax,%r12,4), %rbx
	.p2align 4,,10
	.p2align 3
.L13:
	movq	%rbx, %rsi
	movq	%r13, %rdi
	xorl	%eax, %eax
	addl	$1, %r15d
	call	__isoc99_scanf@PLT
	movslq	-60(%rbp), %rax
	addq	$4, %rbx
	cmpl	%r15d, %eax
	jg	.L13
	addl	$1, %r14d
	cmpl	%r14d, %eax
	jle	.L60
	addq	-80(%rbp), %r12
	jmp	.L12
.L60:
	movq	-80(%rbp), %r15
	movq	-72(%rbp), %rbx
	movq	-112(%rbp), %r12
	testl	%eax, %eax
	jle	.L16
	movq	%r12, %rcx
	leaq	0(,%rax,4), %r13
	movl	$3, %r14d
.L19:
	movq	%rcx, %rdi
	movq	%r13, %rdx
	xorl	%esi, %esi
	call	memset@PLT
	movq	-88(%rbp), %rcx
	addq	%rax, %rcx
	subl	$1, %r14d
	jne	.L19
.L16:
	movl	-64(%rbp), %eax
	testl	%eax, %eax
	jle	.L17
	movq	-104(%rbp), %rax
	movq	$0, -80(%rbp)
	xorl	%r14d, %r14d
	leaq	.LC1(%rip), %r13
	movq	%r15, -72(%rbp)
	shrq	$2, %rax
	movq	%rbx, -104(%rbp)
	movq	%rax, -88(%rbp)
.L18:
	movq	-96(%rbp), %rax
	movq	-80(%rbp), %rsi
	xorl	%ebx, %ebx
	leaq	(%rax,%rsi,4), %r15
	.p2align 4,,10
	.p2align 3
.L20:
	movq	%r15, %rsi
	movq	%r13, %rdi
	xorl	%eax, %eax
	addq	$4, %r15
	call	__isoc99_scanf@PLT
	movl	-4(%r15), %eax
	movl	$2863311531, %esi
	leal	-1(%rax), %edi
	leal	(%r14,%rbx), %eax
	addl	$1, %ebx
	movq	%rax, %r8
	imulq	%rsi, %rax
	movl	%edi, -4(%r15)
	movslq	%edi, %rdi
	shrq	$33, %rax
	leal	(%rax,%rax,2), %r9d
	movl	%r8d, %eax
	subl	%r9d, %eax
	cltq
	imulq	-72(%rbp), %rax
	addq	%rdi, %rax
	addl	$1, (%r12,%rax,4)
	movl	-64(%rbp), %eax
	cmpl	%ebx, %eax
	jg	.L20
	addl	$1, %r14d
	cmpl	%r14d, %eax
	jle	.L61
	movq	-88(%rbp), %rsi
	addq	%rsi, -80(%rbp)
	jmp	.L18
.L61:
	movq	-72(%rbp), %r15
	movq	-104(%rbp), %rbx
.L17:
	movslq	-60(%rbp), %rax
	movl	%eax, -96(%rbp)
	testl	%eax, %eax
	jle	.L33
	leaq	0(,%r15,4), %r13
	movl	$0, -88(%rbp)
	movl	$2147483647, -104(%rbp)
	leaq	(%r12,%r13), %r14
	movq	%rax, -120(%rbp)
	addq	%r14, %r13
.L28:
	movl	$0, -80(%rbp)
	movslq	-88(%rbp), %r11
	.p2align 4,,10
	.p2align 3
.L27:
	movl	-80(%rbp), %eax
	cmpl	%eax, -88(%rbp)
	je	.L23
	xorl	%r8d, %r8d
	movslq	%eax, %r10
	.p2align 4,,10
	.p2align 3
.L26:
	cmpl	%r8d, -88(%rbp)
	je	.L24
	cmpl	%r8d, -80(%rbp)
	je	.L24
	movq	-120(%rbp), %rax
	movl	%r8d, -112(%rbp)
	xorl	%ecx, %ecx
	xorl	%esi, %esi
	movslq	%r8d, %r9
	movq	%rax, -72(%rbp)
	.p2align 4,,10
	.p2align 3
.L25:
	movslq	%ecx, %rdx
	movl	(%r12,%rcx,4), %edi
	movl	(%r14,%rcx,4), %r8d
	imulq	%r15, %rdx
	leaq	(%r11,%rdx), %rax
	imull	(%rbx,%rax,4), %edi
	leaq	(%r10,%rdx), %rax
	addq	%r9, %rdx
	imull	(%rbx,%rax,4), %r8d
	movl	%r8d, %eax
	addl	%edi, %eax
	movl	0(%r13,%rcx,4), %edi
	imull	(%rbx,%rdx,4), %edi
	addq	$1, %rcx
	addl	%edi, %eax
	addl	%eax, %esi
	cmpq	%rcx, -72(%rbp)
	jne	.L25
	movl	-104(%rbp), %eax
	movl	-112(%rbp), %r8d
	cmpl	%esi, %eax
	cmovle	%eax, %esi
	movl	%esi, -104(%rbp)
.L24:
	addl	$1, %r8d
	cmpl	-96(%rbp), %r8d
	jne	.L26
.L23:
	addl	$1, -80(%rbp)
	movl	-80(%rbp), %eax
	cmpl	-96(%rbp), %eax
	jne	.L27
	addl	$1, -88(%rbp)
	movl	-88(%rbp), %eax
	cmpl	-96(%rbp), %eax
	jne	.L28
.L22:
	movl	-104(%rbp), %edx
	xorl	%eax, %eax
	movl	$1, %edi
	leaq	.LC2(%rip), %rsi
	call	__printf_chk@PLT
	movq	-56(%rbp), %rax
	subq	%fs:40, %rax
	jne	.L62
	leaq	-40(%rbp), %rsp
	xorl	%eax, %eax
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	.cfi_remember_state
	.cfi_def_cfa 7, 8
	ret
.L33:
	.cfi_restore_state
	movl	$2147483647, -104(%rbp)
	jmp	.L22
.L62:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE23:
	.size	main, .-main
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:

rule
	.file	"temp.c"
	.text
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d%d"
.LC1:
	.string	"%d"
.LC2:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB23:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	leaq	.LC0(%rip), %rdi
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	pushq	%r15
	pushq	%r14
	leaq	-60(%rbp), %rdx
	leaq	-64(%rbp), %rsi
	pushq	%r13
	pushq	%r12
	pushq	%rbx
	subq	$88, %rsp
	.cfi_offset 15, -24
	.cfi_offset 14, -32
	.cfi_offset 13, -40
	.cfi_offset 12, -48
	.cfi_offset 3, -56
	movq	%fs:40, %rax
	movq	%rax, -56(%rbp)
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movslq	-60(%rbp), %rax
	movq	%rsp, %rdi
	movq	%rax, %rdx
	leaq	0(,%rax,4), %rsi
	movq	%rax, %rcx
	imulq	%rax, %rdx
	movq	%rsi, -88(%rbp)
	leaq	15(,%rdx,4), %rsi
	movq	%rsi, %rdx
	andq	$-4096, %rsi
	subq	%rsi, %rdi
	andq	$-16, %rdx
	cmpq	%rdi, %rsp
	je	.L3
.L57:
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	cmpq	%rdi, %rsp
	jne	.L57
.L3:
	andl	$4095, %edx
	subq	%rdx, %rsp
	testq	%rdx, %rdx
	jne	.L58
.L4:
	movslq	-64(%rbp), %rdx
	movq	%rsp, %rdi
	movq	%rsp, %rbx
	leaq	0(,%rdx,4), %rsi
	imulq	%rdx, %rdx
	movq	%rsi, -104(%rbp)
	leaq	15(,%rdx,4), %rsi
	movq	%rsi, %rdx
	andq	$-4096, %rsi
	andq	$-16, %rdx
	subq	%rsi, %rdi
.L5:
	cmpq	%rdi, %rsp
	je	.L6
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	jmp	.L5
.L58:
	orq	$0, -8(%rsp,%rdx)
	jmp	.L4
.L6:
	andl	$4095, %edx
	subq	%rdx, %rsp
	testq	%rdx, %rdx
	jne	.L59
.L7:
	leaq	(%rax,%rax,2), %rax
	movq	%rsp, -96(%rbp)
	movq	%rsp, %rsi
	leaq	15(,%rax,4), %rdx
	movq	%rdx, %rax
	andq	$-4096, %rdx
	andq	$-16, %rax
	subq	%rdx, %rsi
.L8:
	cmpq	%rsi, %rsp
	je	.L9
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	jmp	.L8
.L59:
	orq	$0, -8(%rsp,%rdx)
	jmp	.L7
.L9:
	andl	$4095, %eax
	subq	%rax, %rsp
	testq	%rax, %rax
	je	.L10
	orq	$0, -8(%rsp,%rax)
.L10:
	movq	-88(%rbp), %r15
	movq	%rsp, %r12
	shrq	$2, %r15
	testl	%ecx, %ecx
	jle	.L16
	movq	%r15, -80(%rbp)
	xorl	%eax, %eax
	xorl	%r14d, %r14d
	leaq	.LC1(%rip), %r13
	movq	%rbx, -72(%rbp)
	movq	%r12, -112(%rbp)
	movq	%rax, %r12
.L12:
	movq	-72(%rbp), %rax
	xorl	%r15d, %r15d
	leaq	(%rax,%r12,4), %rbx
	.p2align 4,,10
	.p2align 3
.L13:
	movq	%rbx, %rsi
	movq	%r13, %rdi
	xorl	%eax, %eax
	addl	$1, %r15d
	call	__isoc99_scanf@PLT
	movslq	-60(%rbp), %rax
	addq	$4, %rbx
	cmpl	%r15d, %eax
	jg	.L13
	addl	$1, %r14d
	cmpl	%r14d, %eax
	jle	.L60
	addq	-80(%rbp), %r12
	jmp	.L12
.L60:
	movq	-80(%rbp), %r15
	movq	-72(%rbp), %rbx
	movq	-112(%rbp), %r12
	testl	%eax, %eax
	jle	.L16
	movq	%r12, %rcx
	leaq	0(,%rax,4), %r13
	movl	$3, %r14d
.L19:
	movq	%rcx, %rdi
	movq	%r13, %rdx
	xorl	%esi, %esi
	call	memset@PLT
	movq	-88(%rbp), %rcx
	addq	%rax, %rcx
	subl	$1, %r14d
	jne	.L19
.L16:
	movl	-64(%rbp), %eax
	testl	%eax, %eax
	jle	.L17
	movq	-104(%rbp), %rax
	movq	$0, -80(%rbp)
	xorl	%r14d, %r14d
	leaq	.LC1(%rip), %r13
	movq	%r15, -72(%rbp)
	shrq	$2, %rax
	movq	%rbx, -104(%rbp)
	movq	%rax, -88(%rbp)
.L18:
	movq	-96(%rbp), %rax
	movq	-80(%rbp), %rsi
	xorl	%ebx, %ebx
	leaq	(%rax,%rsi,4), %r15
	.p2align 4,,10
	.p2align 3
.L20:
	movq	%r15, %rsi
	movq	%r13, %rdi
	xorl	%eax, %eax
	addq	$4, %r15
	call	__isoc99_scanf@PLT
	movl	-4(%r15), %eax
	movl	$2863311531, %esi
	leal	-1(%rax), %edi
	leal	(%r14,%rbx), %eax
	addl	$1, %ebx
	movq	%rax, %r8
	imulq	%rsi, %rax
	movl	%edi, -4(%r15)
	movslq	%edi, %rdi
	shrq	$33, %rax
	leal	(%rax,%rax,2), %r9d
	movl	%r8d, %eax
	subl	%r9d, %eax
	cltq
	imulq	-72(%rbp), %rax
	addq	%rdi, %rax
	addl	$1, (%r12,%rax,4)
	movl	-64(%rbp), %eax
	cmpl	%ebx, %eax
	jg	.L20
	addl	$1, %r14d
	cmpl	%r14d, %eax
	jle	.L61
	movq	-88(%rbp), %rsi
	addq	%rsi, -80(%rbp)
	jmp	.L18
.L61:
	movq	-72(%rbp), %r15
	movq	-104(%rbp), %rbx
.L17:
	movslq	-60(%rbp), %rax
	movl	%eax, -96(%rbp)
	testl	%eax, %eax
	jle	.L33
	leaq	0(,%r15,4), %r13
	movl	$0, -88(%rbp)
	movl	$2147483647, -104(%rbp)
	leaq	(%r12,%r13), %r14
	movq	%rax, -120(%rbp)
	addq	%r14, %r13
.L28:
	movl	$0, -80(%rbp)
	movslq	-88(%rbp), %r11
	.p2align 4,,10
	.p2align 3
.L27:
	movl	-80(%rbp), %eax
	cmpl	%eax, -88(%rbp)
	je	.L23
	xorl	%r8d, %r8d
	movslq	%eax, %r10
	.p2align 4,,10
	.p2align 3
.L26:
	cmpl	%r8d, -88(%rbp)
	je	.L24
	cmpl	%r8d, -80(%rbp)
	je	.L24
	movq	-120(%rbp), %rax
	movl	%r8d, -112(%rbp)
	xorl	%ecx, %ecx
	xorl	%esi, %esi
	movslq	%r8d, %r9
	movq	%rax, -72(%rbp)
	.p2align 4,,10
	.p2align 3
.L25:
	movslq	%ecx, %rdx
	movl	(%r12,%rcx,4), %edi
	movl	(%r14,%rcx,4), %r8d
	imulq	%r15, %rdx
	leaq	(%r11,%rdx), %rax
	imull	(%rbx,%rax,4), %edi
	leaq	(%r10,%rdx), %rax
	addq	%r9, %rdx
	imull	(%rbx,%rax,4), %r8d
	movl	%r8d, %eax
	addl	%edi, %eax
	movl	0(%r13,%rcx,4), %edi
	imull	(%rbx,%rdx,4), %edi
	addq	$1, %rcx
	addl	%edi, %eax
	addl	%eax, %esi
	cmpq	%rcx, -72(%rbp)
	jne	.L25
	movl	-104(%rbp), %eax
	movl	-112(%rbp), %r8d
	cmpl	%esi, %eax
	cmovle	%eax, %esi
	movl	%esi, -104(%rbp)
.L24:
	addl	$1, %r8d
	cmpl	-96(%rbp), %r8d
	jne	.L26
.L23:
	addl	$1, -80(%rbp)
	movl	-80(%rbp), %eax
	cmpl	-96(%rbp), %eax
	jne	.L27
	addl	$1, -88(%rbp)
	movl	-88(%rbp), %eax
	cmpl	-96(%rbp), %eax
	jne	.L28
.L22:
	movl	-104(%rbp), %edx
	xorl	%eax, %eax
	movl	$1, %edi
	leaq	.LC2(%rip), %rsi
	call	__printf_chk@PLT
	movq	-56(%rbp), %rax
	subq	%fs:40, %rax
	jne	.L62
	leaq	-40(%rbp), %rsp
	xorl	%eax, %eax
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	.cfi_remember_state
	.cfi_def_cfa 7, 8
	ret
.L33:
	.cfi_restore_state
	movl	$2147483647, -104(%rbp)
	jmp	.L22
.L62:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE23:
	.size	main, .-main
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:

//WA

#include <stdio.h>
//#include <stdlib.h>
//#include <string.h>
#include <limits.h>
//#include <math.h>

int main() {
  int n, c;
  scanf("%d%d", &n, &c);
  int d[c][c], g[n][n], cnt[3][c];
  for (int i=0; i<c; i++) for (int j=0; j<c; j++) scanf("%d", &(d[i][j]));
  for (int i=0; i<3; i++) for (int j=0; j<c; j++) cnt[i][j] = 0;
  for (int i=0; i<n; i++) for (int j=0; j<n; j++) {
    scanf("%d", &(g[i][j]));
    g[i][j]--;
    cnt[(i+j)%3][g[i][j]]++;
  }
  int ans = INT_MAX, sum;
  for (int i=0; i<c; i++) {
    for (int j=0; j<c; j++) {
      if (i == j) continue;
      for (int k=0; k<c; k++) {
        if (i == k || j == k) continue;
        sum = 0;
        for (int l=0; l<c; l++) sum += cnt[0][l]*d[l][i] + cnt[1][l]*d[l][j] + cnt[2][l]*d[l][k];
        ans = (ans < sum) ? ans : sum;
      }
    }
  }
  printf("%d\n", ans);
  return 0;
}

2 3
0 1 1
1 1 1
1 4 0
1 2
3 3
 2 3
0 1 1
1 1 1
2 4 0
1 2
3 3
 2 3
0 1 1
1 0 1
1 4 0
1 2
1 3
 2 3
0 2 1
1 1 1
2 4 0
1 2
3 3
 2 3
0 1 1
1 0 1
1 4 0
1 2
2 3
 2 3
0 1 1
1 0 1
1 4 -1
1 2
2 3
 2 3
0 2 1
1 1 1
2 2 -1
1 2
3 3
 4 3
0 0 71
81 0 53
14 92 0
1 1 2 1
2 1 1 2
2 2 1 3
1 1 2 2
 2 3
1 3 1
1 1 1
2 4 0
1 2
3 3
 2 3
-2 1 1
1 0 1
1 4 0
1 2
2 3

3
 4
 1
 5
 0
 -1
 2
 392
 6
 -2

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

```c
//WA

#include <stdio.h>
//#include <stdlib.h>
//#include <string.h>
#include <limits.h>
//#include <math.h>

int main() {
  int n, c;
  scanf("%d%d", &n, &c);
  int d[c][c], g[n][n], cnt[3][c];
  for (int i=0; i<c; i++) for (int j=0; j<c; j++) scanf("%d", &(d[i][j]));
  for (int i=0; i<3; i++) for (int j=0; j<c; j++) cnt[i][j] = 0;
  for (int i=0; i<n; i++) for (int j=0; j<n; j++) {
    scanf("%d", &(g[i][j]));
    g[i][j]--;
    cnt[(i+j)%3][g[i][j]]++;
  }
  int ans = INT_MAX, sum;
  for (int i=0; i<c; i++) {
    for (int j=0; j<c; j++) {
      if (i == j) continue;
      for (int k=0; k<c; k++) {
        if (i == k || j == k) continue;
        sum = 0;
        for (int l=0; l<c; l++) sum += cnt[0][l]*d[l][i] + cnt[1][l]*d[l][j] + cnt[2][l]*d[l][k];
        ans = (ans < sum) ? ans : sum;
      }
    }
  }
  printf("%d\n", ans);
  return 0;
}
```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%d%d"
.LC1:
	.string	"%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
	pushq	%r15
	pushq	%r14
	pushq	%r13
	pushq	%r12
	pushq	%rbx
	subq	$328, %rsp
	.cfi_offset 15, -24
	.cfi_offset 14, -32
	.cfi_offset 13, -40
	.cfi_offset 12, -48
	.cfi_offset 3, -56
	movq	%fs:40, %rax
	movq	%rax, -56(%rbp)
	xorl	%eax, %eax
	movq	%rsp, %rax
	movq	%rax, -360(%rbp)
	leaq	-172(%rbp), %rdx
	leaq	-176(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-172(%rbp), %esi
	movl	-172(%rbp), %edi
	movslq	%esi, %rax
	subq	$1, %rax
	movq	%rax, -120(%rbp)
	movslq	%esi, %rax
	movq	%rax, -192(%rbp)
	movq	$0, -184(%rbp)
	movslq	%esi, %rax
	salq	$2, %rax
	movq	%rax, -192(%rbp)
	movslq	%edi, %rax
	subq	$1, %rax
	movq	%rax, -112(%rbp)
	movslq	%esi, %rax
	movq	%rax, %r14
	movl	$0, %r15d
	movslq	%edi, %rax
	movq	%rax, %r12
	movl	$0, %r13d
	movq	%r15, %rdx
	imulq	%r12, %rdx
	movq	%r13, %rax
	imulq	%r14, %rax
	leaq	(%rdx,%rax), %rcx
	movq	%r14, %rax
	mulq	%r12
	addq	%rdx, %rcx
	movq	%rcx, %rdx
	movslq	%esi, %rax
	movq	%rax, -208(%rbp)
	movq	$0, -200(%rbp)
	movslq	%edi, %rax
	movq	%rax, -224(%rbp)
	movq	$0, -216(%rbp)
	movq	-208(%rbp), %r9
	movq	-200(%rbp), %r10
	movq	%r10, %rdx
	movq	-224(%rbp), %r11
	movq	-216(%rbp), %r12
	imulq	%r11, %rdx
	movq	%r12, %rax
	imulq	%r9, %rax
	leaq	(%rdx,%rax), %rcx
	movq	%r9, %rax
	mulq	%r11
	addq	%rdx, %rcx
	movq	%rcx, %rdx
	movslq	%esi, %rdx
	movslq	%edi, %rax
	imulq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	movl	$16, %eax
	subq	$1, %rax
	addq	%rdx, %rax
	movl	$16, %ebx
	movl	$0, %edx
	divq	%rbx
	imulq	$16, %rax, %rdx
	movq	%rdx, %rax
	andq	$-4096, %rax
	movq	%rsp, %rcx
	subq	%rax, %rcx
.L2:
	cmpq	%rcx, %rsp
	je	.L3
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	jmp	.L2
.L3:
	movq	%rdx, %rax
	andl	$4095, %eax
	subq	%rax, %rsp
	movq	%rdx, %rax
	andl	$4095, %eax
	testq	%rax, %rax
	je	.L4
	movq	%rdx, %rax
	andl	$4095, %eax
	subq	$8, %rax
	addq	%rsp, %rax
	orq	$0, (%rax)
.L4:
	movq	%rsp, %rax
	addq	$3, %rax
	shrq	$2, %rax
	salq	$2, %rax
	movq	%rax, -104(%rbp)
	movl	-176(%rbp), %esi
	movl	-176(%rbp), %edi
	movslq	%esi, %rax
	subq	$1, %rax
	movq	%rax, -96(%rbp)
	movslq	%esi, %rax
	movq	%rax, -336(%rbp)
	movq	$0, -328(%rbp)
	movslq	%esi, %rax
	leaq	0(,%rax,4), %r12
	movslq	%edi, %rax
	subq	$1, %rax
	movq	%rax, -88(%rbp)
	movslq	%esi, %rax
	movq	%rax, -240(%rbp)
	movq	$0, -232(%rbp)
	movslq	%edi, %rax
	movq	%rax, -256(%rbp)
	movq	$0, -248(%rbp)
	movq	-240(%rbp), %r9
	movq	-232(%rbp), %r10
	movq	%r10, %rdx
	movq	-256(%rbp), %r14
	movq	-248(%rbp), %r15
	imulq	%r14, %rdx
	movq	%r15, %rax
	imulq	%r9, %rax
	leaq	(%rdx,%rax), %rcx
	movq	%r9, %rax
	mulq	%r14
	addq	%rdx, %rcx
	movq	%rcx, %rdx
	movslq	%esi, %rax
	movq	%rax, -272(%rbp)
	movq	$0, -264(%rbp)
	movslq	%edi, %rax
	movq	%rax, -288(%rbp)
	movq	$0, -280(%rbp)
	movq	-272(%rbp), %r9
	movq	-264(%rbp), %r10
	movq	%r10, %rdx
	movq	-288(%rbp), %r14
	movq	-280(%rbp), %r15
	imulq	%r14, %rdx
	movq	%r15, %rax
	imulq	%r9, %rax
	leaq	(%rdx,%rax), %rcx
	movq	%r9, %rax
	mulq	%r14
	addq	%rdx, %rcx
	movq	%rcx, %rdx
	movslq	%esi, %rdx
	movslq	%edi, %rax
	imulq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	movl	$16, %eax
	subq	$1, %rax
	addq	%rdx, %rax
	movl	$16, %ebx
	movl	$0, %edx
	divq	%rbx
	imulq	$16, %rax, %rax
	movq	%rax, %rcx
	andq	$-4096, %rcx
	movq	%rsp, %rdx
	subq	%rcx, %rdx
.L5:
	cmpq	%rdx, %rsp
	je	.L6
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	jmp	.L5
.L6:
	movq	%rax, %rdx
	andl	$4095, %edx
	subq	%rdx, %rsp
	movq	%rax, %rdx
	andl	$4095, %edx
	testq	%rdx, %rdx
	je	.L7
	andl	$4095, %eax
	subq	$8, %rax
	addq	%rsp, %rax
	orq	$0, (%rax)
.L7:
	movq	%rsp, %rax
	addq	$3, %rax
	shrq	$2, %rax
	salq	$2, %rax
	movq	%rax, -80(%rbp)
	movl	-172(%rbp), %ecx
	movslq	%ecx, %rax
	subq	$1, %rax
	movq	%rax, -72(%rbp)
	movslq	%ecx, %rax
	movq	%rax, -352(%rbp)
	movq	$0, -344(%rbp)
	movslq	%ecx, %rax
	leaq	0(,%rax,4), %rbx
	movslq	%ecx, %rax
	movq	%rax, -304(%rbp)
	movq	$0, -296(%rbp)
	movq	-304(%rbp), %r10
	movq	-296(%rbp), %r11
	imulq	$96, %r11, %rdx
	imulq	$0, %r10, %rax
	leaq	(%rdx,%rax), %rsi
	movl	$96, %eax
	mulq	%r10
	addq	%rdx, %rsi
	movq	%rsi, %rdx
	movslq	%ecx, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	movslq	%ecx, %rax
	movq	%rax, -320(%rbp)
	movq	$0, -312(%rbp)
	movq	-320(%rbp), %r8
	movq	-312(%rbp), %r9
	imulq	$96, %r9, %rdx
	imulq	$0, %r8, %rax
	leaq	(%rdx,%rax), %rsi
	movl	$96, %eax
	mulq	%r8
	addq	%rdx, %rsi
	movq	%rsi, %rdx
	movslq	%ecx, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	movq	%rax, %rdx
	movl	$16, %eax
	subq	$1, %rax
	addq	%rdx, %rax
	movl	$16, %edi
	movl	$0, %edx
	divq	%rdi
	imulq	$16, %rax, %rax
	movq	%rax, %rcx
	andq	$-4096, %rcx
	movq	%rsp, %rdx
	subq	%rcx, %rdx
.L8:
	cmpq	%rdx, %rsp
	je	.L9
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	jmp	.L8
.L9:
	movq	%rax, %rdx
	andl	$4095, %edx
	subq	%rdx, %rsp
	movq	%rax, %rdx
	andl	$4095, %edx
	testq	%rdx, %rdx
	je	.L10
	andl	$4095, %eax
	subq	$8, %rax
	addq	%rsp, %rax
	orq	$0, (%rax)
.L10:
	movq	%rsp, %rax
	addq	$3, %rax
	shrq	$2, %rax
	salq	$2, %rax
	movq	%rax, -64(%rbp)
	movl	$0, -168(%rbp)
	jmp	.L11
.L14:
	movl	$0, -164(%rbp)
	jmp	.L12
.L13:
	movq	-192(%rbp), %rdx
	shrq	$2, %rdx
	movl	-164(%rbp), %eax
	movslq	%eax, %rcx
	movl	-168(%rbp), %eax
	cltq
	imulq	%rdx, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rdx
	movq	-104(%rbp), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -164(%rbp)
.L12:
	movl	-172(%rbp), %eax
	cmpl	%eax, -164(%rbp)
	jl	.L13
	addl	$1, -168(%rbp)
.L11:
	movl	-172(%rbp), %eax
	cmpl	%eax, -168(%rbp)
	jl	.L14
	movl	$0, -160(%rbp)
	jmp	.L15
.L18:
	movl	$0, -156(%rbp)
	jmp	.L16
.L17:
	movq	%rbx, %rcx
	shrq	$2, %rcx
	movq	-64(%rbp), %rax
	movl	-156(%rbp), %edx
	movslq	%edx, %rsi
	movl	-160(%rbp), %edx
	movslq	%edx, %rdx
	imulq	%rcx, %rdx
	addq	%rsi, %rdx
	movl	$0, (%rax,%rdx,4)
	addl	$1, -156(%rbp)
.L16:
	movl	-172(%rbp), %eax
	cmpl	%eax, -156(%rbp)
	jl	.L17
	addl	$1, -160(%rbp)
.L15:
	cmpl	$2, -160(%rbp)
	jle	.L18
	movl	$0, -152(%rbp)
	jmp	.L19
.L22:
	movl	$0, -148(%rbp)
	jmp	.L20
.L21:
	movq	%r12, %rdx
	shrq	$2, %rdx
	movl	-148(%rbp), %eax
	movslq	%eax, %rcx
	movl	-152(%rbp), %eax
	cltq
	imulq	%rdx, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rdx
	movq	-80(%rbp), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movq	%r12, %rax
	shrq	$2, %rax
	movq	-80(%rbp), %rdx
	movl	-148(%rbp), %ecx
	movslq	%ecx, %rsi
	movl	-152(%rbp), %ecx
	movslq	%ecx, %rcx
	imulq	%rax, %rcx
	addq	%rsi, %rcx
	movl	(%rdx,%rcx,4), %edx
	leal	-1(%rdx), %ecx
	movq	-80(%rbp), %rdx
	movl	-148(%rbp), %esi
	movslq	%esi, %rdi
	movl	-152(%rbp), %esi
	movslq	%esi, %rsi
	imulq	%rsi, %rax
	addq	%rdi, %rax
	movl	%ecx, (%rdx,%rax,4)
	movq	%rbx, %rsi
	shrq	$2, %rsi
	movl	-152(%rbp), %edx
	movl	-148(%rbp), %eax
	addl	%eax, %edx
	movslq	%edx, %rax
	imulq	$1431655766, %rax, %rax
	shrq	$32, %rax
	movl	%edx, %ecx
	sarl	$31, %ecx
	subl	%ecx, %eax
	movl	%eax, %ecx
	addl	%ecx, %ecx
	addl	%eax, %ecx
	movl	%edx, %eax
	subl	%ecx, %eax
	movq	%r12, %rdi
	shrq	$2, %rdi
	movq	-80(%rbp), %rdx
	movl	-148(%rbp), %ecx
	movslq	%ecx, %r8
	movl	-152(%rbp), %ecx
	movslq	%ecx, %rcx
	imulq	%rdi, %rcx
	addq	%r8, %rcx
	movl	(%rdx,%rcx,4), %edx
	movq	-64(%rbp), %rcx
	movslq	%edx, %r8
	movslq	%eax, %rdi
	imulq	%rsi, %rdi
	addq	%r8, %rdi
	movl	(%rcx,%rdi,4), %ecx
	leal	1(%rcx), %edi
	movq	-64(%rbp), %rcx
	movslq	%edx, %rdx
	cltq
	imulq	%rsi, %rax
	addq	%rdx, %rax
	movl	%edi, (%rcx,%rax,4)
	addl	$1, -148(%rbp)
.L20:
	movl	-176(%rbp), %eax
	cmpl	%eax, -148(%rbp)
	jl	.L21
	addl	$1, -152(%rbp)
.L19:
	movl	-176(%rbp), %eax
	cmpl	%eax, -152(%rbp)
	jl	.L22
	movl	$2147483647, -144(%rbp)
	movl	$0, -136(%rbp)
	jmp	.L23
.L35:
	movl	$0, -132(%rbp)
	jmp	.L24
.L34:
	movl	-136(%rbp), %eax
	cmpl	-132(%rbp), %eax
	je	.L38
	movl	$0, -128(%rbp)
	jmp	.L27
.L33:
	movl	-136(%rbp), %eax
	cmpl	-128(%rbp), %eax
	je	.L39
	movl	-132(%rbp), %eax
	cmpl	-128(%rbp), %eax
	je	.L39
	movl	$0, -140(%rbp)
	movl	$0, -124(%rbp)
	jmp	.L31
.L32:
	movq	-64(%rbp), %rax
	movl	-124(%rbp), %edx
	movslq	%edx, %rdx
	movl	(%rax,%rdx,4), %edx
	movq	-192(%rbp), %r11
	movq	%r11, %rsi
	shrq	$2, %rsi
	movq	-104(%rbp), %rax
	movl	-136(%rbp), %ecx
	movslq	%ecx, %rdi
	movl	-124(%rbp), %ecx
	movslq	%ecx, %rcx
	imulq	%rsi, %rcx
	addq	%rdi, %rcx
	movl	(%rax,%rcx,4), %eax
	movl	%edx, %edi
	imull	%eax, %edi
	movq	%rbx, %rcx
	shrq	$2, %rcx
	movq	-64(%rbp), %rax
	movl	-124(%rbp), %edx
	movslq	%edx, %rdx
	addq	%rcx, %rdx
	movl	(%rax,%rdx,4), %edx
	movq	%r11, %rsi
	shrq	$2, %rsi
	movq	-104(%rbp), %rax
	movl	-132(%rbp), %ecx
	movslq	%ecx, %r8
	movl	-124(%rbp), %ecx
	movslq	%ecx, %rcx
	imulq	%rsi, %rcx
	addq	%r8, %rcx
	movl	(%rax,%rcx,4), %eax
	imull	%edx, %eax
	leal	(%rdi,%rax), %r8d
	movq	%rbx, %rcx
	shrq	$2, %rcx
	movq	-64(%rbp), %rax
	movl	-124(%rbp), %edx
	movslq	%edx, %rdx
	addq	%rcx, %rcx
	addq	%rcx, %rdx
	movl	(%rax,%rdx,4), %edx
	movq	%r11, %rsi
	shrq	$2, %rsi
	movq	-104(%rbp), %rax
	movl	-128(%rbp), %ecx
	movslq	%ecx, %rdi
	movl	-124(%rbp), %ecx
	movslq	%ecx, %rcx
	imulq	%rsi, %rcx
	addq	%rdi, %rcx
	movl	(%rax,%rcx,4), %eax
	imull	%edx, %eax
	addl	%r8d, %eax
	addl	%eax, -140(%rbp)
	addl	$1, -124(%rbp)
.L31:
	movl	-172(%rbp), %eax
	cmpl	%eax, -124(%rbp)
	jl	.L32
	movl	-144(%rbp), %edx
	movl	-140(%rbp), %eax
	cmpl	%eax, %edx
	cmovle	%edx, %eax
	movl	%eax, -144(%rbp)
	jmp	.L30
.L39:
	nop
.L30:
	addl	$1, -128(%rbp)
.L27:
	movl	-172(%rbp), %eax
	cmpl	%eax, -128(%rbp)
	jl	.L33
	jmp	.L26
.L38:
	nop
.L26:
	addl	$1, -132(%rbp)
.L24:
	movl	-172(%rbp), %eax
	cmpl	%eax, -132(%rbp)
	jl	.L34
	addl	$1, -136(%rbp)
.L23:
	movl	-172(%rbp), %eax
	cmpl	%eax, -136(%rbp)
	jl	.L35
	movl	-144(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	movq	-360(%rbp), %rsp
	movq	-56(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L37
	call	__stack_chk_fail@PLT
.L37:
	leaq	-40(%rbp), %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	main, .-main
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:
```

Only output the optimized assembly code. Do not include any other text. Do not write any comments in the assembly code. Wrap the assembly code in ```assembly``` tags.
train
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%d%d"
.LC1:
	.string	"%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
	pushq	%r15
	pushq	%r14
	pushq	%r13
	pushq	%r12
	pushq	%rbx
	subq	$328, %rsp
	.cfi_offset 15, -24
	.cfi_offset 14, -32
	.cfi_offset 13, -40
	.cfi_offset 12, -48
	.cfi_offset 3, -56
	movq	%fs:40, %rax
	movq	%rax, -56(%rbp)
	xorl	%eax, %eax
	movq	%rsp, %rax
	movq	%rax, -360(%rbp)
	leaq	-172(%rbp), %rdx
	leaq	-176(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-172(%rbp), %esi
	movl	-172(%rbp), %edi
	movslq	%esi, %rax
	subq	$1, %rax
	movq	%rax, -120(%rbp)
	movslq	%esi, %rax
	movq	%rax, -192(%rbp)
	movq	$0, -184(%rbp)
	movslq	%esi, %rax
	salq	$2, %rax
	movq	%rax, -192(%rbp)
	movslq	%edi, %rax
	subq	$1, %rax
	movq	%rax, -112(%rbp)
	movslq	%esi, %rax
	movq	%rax, %r14
	movl	$0, %r15d
	movslq	%edi, %rax
	movq	%rax, %r12
	movl	$0, %r13d
	movq	%r15, %rdx
	imulq	%r12, %rdx
	movq	%r13, %rax
	imulq	%r14, %rax
	leaq	(%rdx,%rax), %rcx
	movq	%r14, %rax
	mulq	%r12
	addq	%rdx, %rcx
	movq	%rcx, %rdx
	movslq	%esi, %rax
	movq	%rax, -208(%rbp)
	movq	$0, -200(%rbp)
	movslq	%edi, %rax
	movq	%rax, -224(%rbp)
	movq	$0, -216(%rbp)
	movq	-208(%rbp), %r9
	movq	-200(%rbp), %r10
	movq	%r10, %rdx
	movq	-224(%rbp), %r11
	movq	-216(%rbp), %r12
	imulq	%r11, %rdx
	movq	%r12, %rax
	imulq	%r9, %rax
	leaq	(%rdx,%rax), %rcx
	movq	%r9, %rax
	mulq	%r11
	addq	%rdx, %rcx
	movq	%rcx, %rdx
	movslq	%esi, %rdx
	movslq	%edi, %rax
	imulq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	movl	$16, %eax
	subq	$1, %rax
	addq	%rdx, %rax
	movl	$16, %ebx
	movl	$0, %edx
	divq	%rbx
	imulq	$16, %rax, %rdx
	movq	%rdx, %rax
	andq	$-4096, %rax
	movq	%rsp, %rcx
	subq	%rax, %rcx
.L2:
	cmpq	%rcx, %rsp
	je	.L3
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	jmp	.L2
.L3:
	movq	%rdx, %rax
	andl	$4095, %eax
	subq	%rax, %rsp
	movq	%rdx, %rax
	andl	$4095, %eax
	testq	%rax, %rax
	je	.L4
	movq	%rdx, %rax
	andl	$4095, %eax
	subq	$8, %rax
	addq	%rsp, %rax
	orq	$0, (%rax)
.L4:
	movq	%rsp, %rax
	addq	$3, %rax
	shrq	$2, %rax
	salq	$2, %rax
	movq	%rax, -104(%rbp)
	movl	-176(%rbp), %esi
	movl	-176(%rbp), %edi
	movslq	%esi, %rax
	subq	$1, %rax
	movq	%rax, -96(%rbp)
	movslq	%esi, %rax
	movq	%rax, -336(%rbp)
	movq	$0, -328(%rbp)
	movslq	%esi, %rax
	leaq	0(,%rax,4), %r12
	movslq	%edi, %rax
	subq	$1, %rax
	movq	%rax, -88(%rbp)
	movslq	%esi, %rax
	movq	%rax, -240(%rbp)
	movq	$0, -232(%rbp)
	movslq	%edi, %rax
	movq	%rax, -256(%rbp)
	movq	$0, -248(%rbp)
	movq	-240(%rbp), %r9
	movq	-232(%rbp), %r10
	movq	%r10, %rdx
	movq	-256(%rbp), %r14
	movq	-248(%rbp), %r15
	imulq	%r14, %rdx
	movq	%r15, %rax
	imulq	%r9, %rax
	leaq	(%rdx,%rax), %rcx
	movq	%r9, %rax
	mulq	%r14
	addq	%rdx, %rcx
	movq	%rcx, %rdx
	movslq	%esi, %rax
	movq	%rax, -272(%rbp)
	movq	$0, -264(%rbp)
	movslq	%edi, %rax
	movq	%rax, -288(%rbp)
	movq	$0, -280(%rbp)
	movq	-272(%rbp), %r9
	movq	-264(%rbp), %r10
	movq	%r10, %rdx
	movq	-288(%rbp), %r14
	movq	-280(%rbp), %r15
	imulq	%r14, %rdx
	movq	%r15, %rax
	imulq	%r9, %rax
	leaq	(%rdx,%rax), %rcx
	movq	%r9, %rax
	mulq	%r14
	addq	%rdx, %rcx
	movq	%rcx, %rdx
	movslq	%esi, %rdx
	movslq	%edi, %rax
	imulq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	movl	$16, %eax
	subq	$1, %rax
	addq	%rdx, %rax
	movl	$16, %ebx
	movl	$0, %edx
	divq	%rbx
	imulq	$16, %rax, %rax
	movq	%rax, %rcx
	andq	$-4096, %rcx
	movq	%rsp, %rdx
	subq	%rcx, %rdx
.L5:
	cmpq	%rdx, %rsp
	je	.L6
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	jmp	.L5
.L6:
	movq	%rax, %rdx
	andl	$4095, %edx
	subq	%rdx, %rsp
	movq	%rax, %rdx
	andl	$4095, %edx
	testq	%rdx, %rdx
	je	.L7
	andl	$4095, %eax
	subq	$8, %rax
	addq	%rsp, %rax
	orq	$0, (%rax)
.L7:
	movq	%rsp, %rax
	addq	$3, %rax
	shrq	$2, %rax
	salq	$2, %rax
	movq	%rax, -80(%rbp)
	movl	-172(%rbp), %ecx
	movslq	%ecx, %rax
	subq	$1, %rax
	movq	%rax, -72(%rbp)
	movslq	%ecx, %rax
	movq	%rax, -352(%rbp)
	movq	$0, -344(%rbp)
	movslq	%ecx, %rax
	leaq	0(,%rax,4), %rbx
	movslq	%ecx, %rax
	movq	%rax, -304(%rbp)
	movq	$0, -296(%rbp)
	movq	-304(%rbp), %r10
	movq	-296(%rbp), %r11
	imulq	$96, %r11, %rdx
	imulq	$0, %r10, %rax
	leaq	(%rdx,%rax), %rsi
	movl	$96, %eax
	mulq	%r10
	addq	%rdx, %rsi
	movq	%rsi, %rdx
	movslq	%ecx, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	movslq	%ecx, %rax
	movq	%rax, -320(%rbp)
	movq	$0, -312(%rbp)
	movq	-320(%rbp), %r8
	movq	-312(%rbp), %r9
	imulq	$96, %r9, %rdx
	imulq	$0, %r8, %rax
	leaq	(%rdx,%rax), %rsi
	movl	$96, %eax
	mulq	%r8
	addq	%rdx, %rsi
	movq	%rsi, %rdx
	movslq	%ecx, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	movq	%rax, %rdx
	movl	$16, %eax
	subq	$1, %rax
	addq	%rdx, %rax
	movl	$16, %edi
	movl	$0, %edx
	divq	%rdi
	imulq	$16, %rax, %rax
	movq	%rax, %rcx
	andq	$-4096, %rcx
	movq	%rsp, %rdx
	subq	%rcx, %rdx
.L8:
	cmpq	%rdx, %rsp
	je	.L9
	subq	$4096, %rsp
	orq	$0, 4088(%rsp)
	jmp	.L8
.L9:
	movq	%rax, %rdx
	andl	$4095, %edx
	subq	%rdx, %rsp
	movq	%rax, %rdx
	andl	$4095, %edx
	testq	%rdx, %rdx
	je	.L10
	andl	$4095, %eax
	subq	$8, %rax
	addq	%rsp, %rax
	orq	$0, (%rax)
.L10:
	movq	%rsp, %rax
	addq	$3, %rax
	shrq	$2, %rax
	salq	$2, %rax
	movq	%rax, -64(%rbp)
	movl	$0, -168(%rbp)
	jmp	.L11
.L14:
	movl	$0, -164(%rbp)
	jmp	.L12
.L13:
	movq	-192(%rbp), %rdx
	shrq	$2, %rdx
	movl	-164(%rbp), %eax
	movslq	%eax, %rcx
	movl	-168(%rbp), %eax
	cltq
	imulq	%rdx, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rdx
	movq	-104(%rbp), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -164(%rbp)
.L12:
	movl	-172(%rbp), %eax
	cmpl	%eax, -164(%rbp)
	jl	.L13
	addl	$1, -168(%rbp)
.L11:
	movl	-172(%rbp), %eax
	cmpl	%eax, -168(%rbp)
	jl	.L14
	movl	$0, -160(%rbp)
	jmp	.L15
.L18:
	movl	$0, -156(%rbp)
	jmp	.L16
.L17:
	movq	%rbx, %rcx
	shrq	$2, %rcx
	movq	-64(%rbp), %rax
	movl	-156(%rbp), %edx
	movslq	%edx, %rsi
	movl	-160(%rbp), %edx
	movslq	%edx, %rdx
	imulq	%rcx, %rdx
	addq	%rsi, %rdx
	movl	$0, (%rax,%rdx,4)
	addl	$1, -156(%rbp)
.L16:
	movl	-172(%rbp), %eax
	cmpl	%eax, -156(%rbp)
	jl	.L17
	addl	$1, -160(%rbp)
.L15:
	cmpl	$2, -160(%rbp)
	jle	.L18
	movl	$0, -152(%rbp)
	jmp	.L19
.L22:
	movl	$0, -148(%rbp)
	jmp	.L20
.L21:
	movq	%r12, %rdx
	shrq	$2, %rdx
	movl	-148(%rbp), %eax
	movslq	%eax, %rcx
	movl	-152(%rbp), %eax
	cltq
	imulq	%rdx, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rdx
	movq	-80(%rbp), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movq	%r12, %rax
	shrq	$2, %rax
	movq	-80(%rbp), %rdx
	movl	-148(%rbp), %ecx
	movslq	%ecx, %rsi
	movl	-152(%rbp), %ecx
	movslq	%ecx, %rcx
	imulq	%rax, %rcx
	addq	%rsi, %rcx
	movl	(%rdx,%rcx,4), %edx
	leal	-1(%rdx), %ecx
	movq	-80(%rbp), %rdx
	movl	-148(%rbp), %esi
	movslq	%esi, %rdi
	movl	-152(%rbp), %esi
	movslq	%esi, %rsi
	imulq	%rsi, %rax
	addq	%rdi, %rax
	movl	%ecx, (%rdx,%rax,4)
	movq	%rbx, %rsi
	shrq	$2, %rsi
	movl	-152(%rbp), %edx
	movl	-148(%rbp), %eax
	addl	%eax, %edx
	movslq	%edx, %rax
	imulq	$1431655766, %rax, %rax
	shrq	$32, %rax
	movl	%edx, %ecx
	sarl	$31, %ecx
	subl	%ecx, %eax
	movl	%eax, %ecx
	addl	%ecx, %ecx
	addl	%eax, %ecx
	movl	%edx, %eax
	subl	%ecx, %eax
	movq	%r12, %rdi
	shrq	$2, %rdi
	movq	-80(%rbp), %rdx
	movl	-148(%rbp), %ecx
	movslq	%ecx, %r8
	movl	-152(%rbp), %ecx
	movslq	%ecx, %rcx
	imulq	%rdi, %rcx
	addq	%r8, %rcx
	movl	(%rdx,%rcx,4), %edx
	movq	-64(%rbp), %rcx
	movslq	%edx, %r8
	movslq	%eax, %rdi
	imulq	%rsi, %rdi
	addq	%r8, %rdi
	movl	(%rcx,%rdi,4), %ecx
	leal	1(%rcx), %edi
	movq	-64(%rbp), %rcx
	movslq	%edx, %rdx
	cltq
	imulq	%rsi, %rax
	addq	%rdx, %rax
	movl	%edi, (%rcx,%rax,4)
	addl	$1, -148(%rbp)
.L20:
	movl	-176(%rbp), %eax
	cmpl	%eax, -148(%rbp)
	jl	.L21
	addl	$1, -152(%rbp)
.L19:
	movl	-176(%rbp), %eax
	cmpl	%eax, -152(%rbp)
	jl	.L22
	movl	$2147483647, -144(%rbp)
	movl	$0, -136(%rbp)
	jmp	.L23
.L35:
	movl	$0, -132(%rbp)
	jmp	.L24
.L34:
	movl	-136(%rbp), %eax
	cmpl	-132(%rbp), %eax
	je	.L38
	movl	$0, -128(%rbp)
	jmp	.L27
.L33:
	movl	-136(%rbp), %eax
	cmpl	-128(%rbp), %eax
	je	.L39
	movl	-132(%rbp), %eax
	cmpl	-128(%rbp), %eax
	je	.L39
	movl	$0, -140(%rbp)
	movl	$0, -124(%rbp)
	jmp	.L31
.L32:
	movq	-64(%rbp), %rax
	movl	-124(%rbp), %edx
	movslq	%edx, %rdx
	movl	(%rax,%rdx,4), %edx
	movq	-192(%rbp), %r11
	movq	%r11, %rsi
	shrq	$2, %rsi
	movq	-104(%rbp), %rax
	movl	-136(%rbp), %ecx
	movslq	%ecx, %rdi
	movl	-124(%rbp), %ecx
	movslq	%ecx, %rcx
	imulq	%rsi, %rcx
	addq	%rdi, %rcx
	movl	(%rax,%rcx,4), %eax
	movl	%edx, %edi
	imull	%eax, %edi
	movq	%rbx, %rcx
	shrq	$2, %rcx
	movq	-64(%rbp), %rax
	movl	-124(%rbp), %edx
	movslq	%edx, %rdx
	addq	%rcx, %rdx
	movl	(%rax,%rdx,4), %edx
	movq	%r11, %rsi
	shrq	$2, %rsi
	movq	-104(%rbp), %rax
	movl	-132(%rbp), %ecx
	movslq	%ecx, %r8
	movl	-124(%rbp), %ecx
	movslq	%ecx, %rcx
	imulq	%rsi, %rcx
	addq	%r8, %rcx
	movl	(%rax,%rcx,4), %eax
	imull	%edx, %eax
	leal	(%rdi,%rax), %r8d
	movq	%rbx, %rcx
	shrq	$2, %rcx
	movq	-64(%rbp), %rax
	movl	-124(%rbp), %edx
	movslq	%edx, %rdx
	addq	%rcx, %rcx
	addq	%rcx, %rdx
	movl	(%rax,%rdx,4), %edx
	movq	%r11, %rsi
	shrq	$2, %rsi
	movq	-104(%rbp), %rax
	movl	-128(%rbp), %ecx
	movslq	%ecx, %rdi
	movl	-124(%rbp), %ecx
	movslq	%ecx, %rcx
	imulq	%rsi, %rcx
	addq	%rdi, %rcx
	movl	(%rax,%rcx,4), %eax
	imull	%edx, %eax
	addl	%r8d, %eax
	addl	%eax, -140(%rbp)
	addl	$1, -124(%rbp)
.L31:
	movl	-172(%rbp), %eax
	cmpl	%eax, -124(%rbp)
	jl	.L32
	movl	-144(%rbp), %edx
	movl	-140(%rbp), %eax
	cmpl	%eax, %edx
	cmovle	%edx, %eax
	movl	%eax, -144(%rbp)
	jmp	.L30
.L39:
	nop
.L30:
	addl	$1, -128(%rbp)
.L27:
	movl	-172(%rbp), %eax
	cmpl	%eax, -128(%rbp)
	jl	.L33
	jmp	.L26
.L38:
	nop
.L26:
	addl	$1, -132(%rbp)
.L24:
	movl	-172(%rbp), %eax
	cmpl	%eax, -132(%rbp)
	jl	.L34
	addl	$1, -136(%rbp)
.L23:
	movl	-172(%rbp), %eax
	cmpl	%eax, -136(%rbp)
	jl	.L35
	movl	-144(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	movq	-360(%rbp), %rsp
	movq	-56(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L37
	call	__stack_chk_fail@PLT
.L37:
	leaq	-40(%rbp), %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	main, .-main
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:
