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

```c
#include <stdio.h>

#define MAX 15

int guchoku(const int *start, const int *goal, int num) {
	int status[MAX];
	int i, j;
	int count = 0;
	for (i = 0; i < num; i++) {
		status[i] = start[i];
	}
	for (i = 0; i < num; i++) {
		if (status[i] != goal[i]) {
			for (j = i + 1; j < num; j++) {
				if (status[j] == goal[i]) break;
			}
			if (j >= num) return MAX * MAX + 10;
			for (; j > i; j--) {
				int temp = status[j];
				status[j] = status[j - 1];
				status[j - 1] = temp;
				count++;
			}
		}
	}
	return count;
}

int main(void) {
	int N, M;
	int b[MAX];
	int p[MAX];
	int target[MAX];
	int start, current, phase, left;
	int i;
	int answer = -1, candidate;
	if (scanf("%d%d", &N, &M) != 2) return 1;
	for (i = 0; i < N; i++) {
		if (scanf("%d", &b[i]) != 1) return 1;
	}
	for (i = 0; i < M; i++) {
		if (scanf("%d", &p[i]) != 1) return 1;
	}
	for (start = 0; start <= 1; start++) {
		current = start;
		phase = 0;
		left = p[0];
		for (i = 0; i < N; i++) {
			target[i] = current;
			left--;
			if (left <= 0) {
				current = 1 - current;
				phase++;
				left = p[phase];
			}
		}
		candidate = guchoku(b, target, N);
		if (answer < 0 || candidate < answer) answer = candidate;
	}
	printf("%d\n", answer);
	return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	guchoku
	.type	guchoku, @function
guchoku:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	addq	$-128, %rsp
	movq	%rdi, -104(%rbp)
	movq	%rsi, -112(%rbp)
	movl	%edx, -116(%rbp)
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	$0, -88(%rbp)
	movl	$0, -96(%rbp)
	jmp	.L2
.L3:
	movl	-96(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-104(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %edx
	movl	-96(%rbp), %eax
	cltq
	movl	%edx, -80(%rbp,%rax,4)
	addl	$1, -96(%rbp)
.L2:
	movl	-96(%rbp), %eax
	cmpl	-116(%rbp), %eax
	jl	.L3
	movl	$0, -96(%rbp)
	jmp	.L4
.L14:
	movl	-96(%rbp), %eax
	cltq
	movl	-80(%rbp,%rax,4), %edx
	movl	-96(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	movq	-112(%rbp), %rax
	addq	%rcx, %rax
	movl	(%rax), %eax
	cmpl	%eax, %edx
	je	.L5
	movl	-96(%rbp), %eax
	addl	$1, %eax
	movl	%eax, -92(%rbp)
	jmp	.L6
.L9:
	movl	-92(%rbp), %eax
	cltq
	movl	-80(%rbp,%rax,4), %edx
	movl	-96(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	movq	-112(%rbp), %rax
	addq	%rcx, %rax
	movl	(%rax), %eax
	cmpl	%eax, %edx
	je	.L17
	addl	$1, -92(%rbp)
.L6:
	movl	-92(%rbp), %eax
	cmpl	-116(%rbp), %eax
	jl	.L9
	jmp	.L8
.L17:
	nop
.L8:
	movl	-92(%rbp), %eax
	cmpl	-116(%rbp), %eax
	jl	.L12
	movl	$235, %eax
	jmp	.L15
.L13:
	movl	-92(%rbp), %eax
	cltq
	movl	-80(%rbp,%rax,4), %eax
	movl	%eax, -84(%rbp)
	movl	-92(%rbp), %eax
	subl	$1, %eax
	cltq
	movl	-80(%rbp,%rax,4), %edx
	movl	-92(%rbp), %eax
	cltq
	movl	%edx, -80(%rbp,%rax,4)
	movl	-92(%rbp), %eax
	subl	$1, %eax
	cltq
	movl	-84(%rbp), %edx
	movl	%edx, -80(%rbp,%rax,4)
	addl	$1, -88(%rbp)
	subl	$1, -92(%rbp)
.L12:
	movl	-92(%rbp), %eax
	cmpl	-96(%rbp), %eax
	jg	.L13
.L5:
	addl	$1, -96(%rbp)
.L4:
	movl	-96(%rbp), %eax
	cmpl	-116(%rbp), %eax
	jl	.L14
	movl	-88(%rbp), %eax
.L15:
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L16
	call	__stack_chk_fail@PLT
.L16:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	guchoku, .-guchoku
	.section	.rodata
.LC0:
	.string	"%d%d"
.LC1:
	.string	"%d"
.LC2:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB1:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$256, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	$-1, -216(%rbp)
	leaq	-240(%rbp), %rdx
	leaq	-244(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	cmpl	$2, %eax
	je	.L19
	movl	$1, %eax
	jmp	.L34
.L19:
	movl	$0, -220(%rbp)
	jmp	.L21
.L23:
	leaq	-208(%rbp), %rdx
	movl	-220(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	cmpl	$1, %eax
	je	.L22
	movl	$1, %eax
	jmp	.L34
.L22:
	addl	$1, -220(%rbp)
.L21:
	movl	-244(%rbp), %eax
	cmpl	%eax, -220(%rbp)
	jl	.L23
	movl	$0, -220(%rbp)
	jmp	.L24
.L26:
	leaq	-144(%rbp), %rdx
	movl	-220(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	cmpl	$1, %eax
	je	.L25
	movl	$1, %eax
	jmp	.L34
.L25:
	addl	$1, -220(%rbp)
.L24:
	movl	-240(%rbp), %eax
	cmpl	%eax, -220(%rbp)
	jl	.L26
	movl	$0, -236(%rbp)
	jmp	.L27
.L33:
	movl	-236(%rbp), %eax
	movl	%eax, -232(%rbp)
	movl	$0, -228(%rbp)
	movl	-144(%rbp), %eax
	movl	%eax, -224(%rbp)
	movl	$0, -220(%rbp)
	jmp	.L28
.L30:
	movl	-220(%rbp), %eax
	cltq
	movl	-232(%rbp), %edx
	movl	%edx, -80(%rbp,%rax,4)
	subl	$1, -224(%rbp)
	cmpl	$0, -224(%rbp)
	jg	.L29
	movl	$1, %eax
	subl	-232(%rbp), %eax
	movl	%eax, -232(%rbp)
	addl	$1, -228(%rbp)
	movl	-228(%rbp), %eax
	cltq
	movl	-144(%rbp,%rax,4), %eax
	movl	%eax, -224(%rbp)
.L29:
	addl	$1, -220(%rbp)
.L28:
	movl	-244(%rbp), %eax
	cmpl	%eax, -220(%rbp)
	jl	.L30
	movl	-244(%rbp), %edx
	leaq	-80(%rbp), %rcx
	leaq	-208(%rbp), %rax
	movq	%rcx, %rsi
	movq	%rax, %rdi
	call	guchoku
	movl	%eax, -212(%rbp)
	cmpl	$0, -216(%rbp)
	js	.L31
	movl	-212(%rbp), %eax
	cmpl	-216(%rbp), %eax
	jge	.L32
.L31:
	movl	-212(%rbp), %eax
	movl	%eax, -216(%rbp)
.L32:
	addl	$1, -236(%rbp)
.L27:
	cmpl	$1, -236(%rbp)
	jle	.L33
	movl	-216(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
.L34:
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L35
	call	__stack_chk_fail@PLT
.L35:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.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
	.p2align 4
	.globl	guchoku
	.type	guchoku, @function
guchoku:
.LFB23:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	pushq	%rbx
	.cfi_def_cfa_offset 24
	.cfi_offset 3, -24
	subq	$88, %rsp
	.cfi_def_cfa_offset 112
	movq	%fs:40, %rax
	movq	%rax, 72(%rsp)
	xorl	%eax, %eax
	testl	%edx, %edx
	jle	.L9
	movq	%rsp, %r8
	movl	%edx, %ebx
	movslq	%edx, %rdx
	movq	%rsi, %rbp
	salq	$2, %rdx
	movq	%rdi, %rsi
	movq	%r8, %rdi
	call	memcpy@PLT
	xorl	%edx, %edx
	xorl	%r9d, %r9d
	movq	%rax, %r8
	movq	%rax, %rcx
	jmp	.L6
	.p2align 4,,10
	.p2align 3
.L3:
	addq	$1, %rdx
	addq	$4, %rcx
	cmpl	%edx, %ebx
	jle	.L1
.L6:
	movl	0(%rbp,%rdx,4), %esi
	movl	%edx, %edi
	leal	1(%rdx), %eax
	cmpl	%esi, (%rcx)
	je	.L3
	cmpl	%eax, %ebx
	jle	.L23
	cmpl	4(%rcx), %esi
	je	.L4
	leal	2(%rdx), %eax
	cmpl	%eax, %ebx
	jle	.L23
	cmpl	8(%rcx), %esi
	je	.L4
	leal	3(%rdx), %eax
	cmpl	%eax, %ebx
	jle	.L23
	cmpl	12(%rcx), %esi
	je	.L4
	leal	4(%rdx), %eax
	cmpl	%eax, %ebx
	jle	.L23
	cmpl	16(%rcx), %esi
	je	.L4
	leal	5(%rdx), %eax
	cmpl	%eax, %ebx
	jle	.L23
	cmpl	20(%rcx), %esi
	je	.L4
	leal	6(%rdx), %eax
	cmpl	%eax, %ebx
	jle	.L23
	cmpl	24(%rcx), %esi
	je	.L4
	leal	7(%rdx), %eax
	cmpl	%eax, %ebx
	jle	.L23
	cmpl	28(%rcx), %esi
	je	.L4
	leal	8(%rdx), %eax
	cmpl	%eax, %ebx
	jle	.L23
	cmpl	32(%rcx), %esi
	je	.L4
	leal	9(%rdx), %eax
	cmpl	%eax, %ebx
	jle	.L23
	cmpl	36(%rcx), %esi
	je	.L4
	leal	10(%rdx), %eax
	cmpl	%eax, %ebx
	jle	.L23
	cmpl	40(%rcx), %esi
	je	.L4
	leal	11(%rdx), %eax
	cmpl	%eax, %ebx
	jle	.L23
	cmpl	44(%rcx), %esi
	je	.L4
	leal	12(%rdx), %eax
	cmpl	%eax, %ebx
	jle	.L23
	cmpl	48(%rcx), %esi
	je	.L4
	leal	13(%rdx), %eax
	cmpl	%eax, %ebx
	jle	.L23
	cmpl	52(%rcx), %esi
	je	.L4
	leal	14(%rdx), %eax
	cmpl	%eax, %ebx
	jle	.L23
	cmpl	56(%rcx), %esi
	je	.L4
.L23:
	movl	$235, %r9d
.L1:
	movq	72(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L27
	addq	$88, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 24
	movl	%r9d, %eax
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L4:
	.cfi_restore_state
	movl	%edx, %esi
	cmpl	%edx, %eax
	jle	.L3
	movslq	%eax, %r10
	movd	(%rsp,%r10,4), %xmm0
	leal	-1(%rax), %r10d
	movslq	%r10d, %r11
	movd	(%rsp,%r11,4), %xmm2
	movdqa	%xmm0, %xmm1
	punpckldq	%xmm2, %xmm1
	movq	%xmm1, (%r8,%r11,4)
	cmpl	%edx, %r10d
	jle	.L5
	leal	-2(%rax), %r10d
	movdqa	%xmm0, %xmm1
	movslq	%r10d, %r11
	movd	(%rsp,%r11,4), %xmm3
	punpckldq	%xmm3, %xmm1
	movq	%xmm1, (%r8,%r11,4)
	cmpl	%esi, %r10d
	jle	.L5
	leal	-3(%rax), %r10d
	movdqa	%xmm0, %xmm1
	movslq	%r10d, %r11
	movd	(%rsp,%r11,4), %xmm4
	punpckldq	%xmm4, %xmm1
	movq	%xmm1, (%r8,%r11,4)
	cmpl	%esi, %r10d
	jle	.L5
	leal	-4(%rax), %r10d
	movdqa	%xmm0, %xmm1
	movslq	%r10d, %r11
	movd	(%rsp,%r11,4), %xmm5
	punpckldq	%xmm5, %xmm1
	movq	%xmm1, (%r8,%r11,4)
	cmpl	%esi, %r10d
	jle	.L5
	leal	-5(%rax), %r10d
	movdqa	%xmm0, %xmm1
	movslq	%r10d, %r11
	movd	(%rsp,%r11,4), %xmm6
	punpckldq	%xmm6, %xmm1
	movq	%xmm1, (%r8,%r11,4)
	cmpl	%esi, %r10d
	jle	.L5
	leal	-6(%rax), %r10d
	movdqa	%xmm0, %xmm1
	movslq	%r10d, %r11
	movd	(%rsp,%r11,4), %xmm7
	punpckldq	%xmm7, %xmm1
	movq	%xmm1, (%r8,%r11,4)
	cmpl	%esi, %r10d
	jle	.L5
	leal	-7(%rax), %r10d
	movdqa	%xmm0, %xmm1
	movslq	%r10d, %r11
	movd	(%rsp,%r11,4), %xmm7
	punpckldq	%xmm7, %xmm1
	movq	%xmm1, (%r8,%r11,4)
	cmpl	%esi, %r10d
	jle	.L5
	leal	-8(%rax), %r10d
	movdqa	%xmm0, %xmm1
	movslq	%r10d, %r11
	movd	(%rsp,%r11,4), %xmm6
	punpckldq	%xmm6, %xmm1
	movq	%xmm1, (%r8,%r11,4)
	cmpl	%r10d, %esi
	jge	.L5
	leal	-9(%rax), %r10d
	movdqa	%xmm0, %xmm1
	movslq	%r10d, %r11
	movd	(%rsp,%r11,4), %xmm5
	punpckldq	%xmm5, %xmm1
	movq	%xmm1, (%r8,%r11,4)
	cmpl	%r10d, %esi
	jge	.L5
	leal	-10(%rax), %r10d
	movdqa	%xmm0, %xmm1
	movslq	%r10d, %r11
	movd	(%rsp,%r11,4), %xmm4
	punpckldq	%xmm4, %xmm1
	movq	%xmm1, (%r8,%r11,4)
	cmpl	%r10d, %esi
	jge	.L5
	leal	-11(%rax), %r10d
	movdqa	%xmm0, %xmm1
	movslq	%r10d, %r11
	movd	(%rsp,%r11,4), %xmm3
	punpckldq	%xmm3, %xmm1
	movq	%xmm1, (%r8,%r11,4)
	cmpl	%r10d, %esi
	jge	.L5
	leal	-12(%rax), %r10d
	movdqa	%xmm0, %xmm1
	movslq	%r10d, %r11
	movd	(%rsp,%r11,4), %xmm2
	punpckldq	%xmm2, %xmm1
	movq	%xmm1, (%r8,%r11,4)
	cmpl	%r10d, %esi
	jge	.L5
	leal	-13(%rax), %r10d
	movdqa	%xmm0, %xmm1
	movslq	%r10d, %r11
	movd	(%rsp,%r11,4), %xmm7
	punpckldq	%xmm7, %xmm1
	movq	%xmm1, (%r8,%r11,4)
	cmpl	%r10d, %esi
	jge	.L5
	movd	(%rsp), %xmm6
	punpckldq	%xmm6, %xmm0
	movq	%xmm0, (%rsp)
.L5:
	subl	%edi, %r9d
	addl	%eax, %r9d
	jmp	.L3
.L9:
	xorl	%r9d, %r9d
	jmp	.L1
.L27:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE23:
	.size	guchoku, .-guchoku
	.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:
.LFB24:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	leaq	.LC0(%rip), %rdi
	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
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$248, %rsp
	.cfi_def_cfa_offset 304
	movq	%fs:40, %rax
	movq	%rax, 232(%rsp)
	xorl	%eax, %eax
	leaq	28(%rsp), %rdx
	leaq	24(%rsp), %rsi
	call	__isoc99_scanf@PLT
	cmpl	$2, %eax
	jne	.L32
	cmpl	$0, 24(%rsp)
	jle	.L31
	leaq	32(%rsp), %rbx
	xorl	%ebp, %ebp
	leaq	.LC1(%rip), %r12
	jmp	.L33
	.p2align 4,,10
	.p2align 3
.L106:
	addl	$1, %ebp
	addq	$4, %rbx
	cmpl	%ebp, 24(%rsp)
	jle	.L31
.L33:
	xorl	%eax, %eax
	movq	%rbx, %rsi
	movq	%r12, %rdi
	call	__isoc99_scanf@PLT
	cmpl	$1, %eax
	je	.L106
.L32:
	movl	$1, %eax
.L28:
	movq	232(%rsp), %rdx
	subq	%fs:40, %rdx
	jne	.L107
	addq	$248, %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
.L31:
	.cfi_restore_state
	cmpl	$0, 28(%rsp)
	jle	.L34
	leaq	96(%rsp), %rbx
	xorl	%ebp, %ebp
	leaq	.LC1(%rip), %r12
	jmp	.L35
	.p2align 4,,10
	.p2align 3
.L108:
	addl	$1, %ebp
	addq	$4, %rbx
	cmpl	%ebp, 28(%rsp)
	jle	.L34
.L35:
	xorl	%eax, %eax
	movq	%rbx, %rsi
	movq	%r12, %rdi
	call	__isoc99_scanf@PLT
	cmpl	$1, %eax
	je	.L108
	jmp	.L32
.L34:
	movl	96(%rsp), %eax
	movl	24(%rsp), %r12d
	orl	$-1, %r14d
	xorl	%r13d, %r13d
	leaq	32(%rsp), %rbx
	leaq	160(%rsp), %rbp
	movl	$1, %r15d
	subl	$1, %eax
	movl	%eax, 8(%rsp)
	movl	100(%rsp), %eax
	movl	%eax, 12(%rsp)
.L53:
	testl	%r12d, %r12d
	jle	.L36
	cmpl	$0, 8(%rsp)
	movl	%r13d, 160(%rsp)
	jle	.L109
	movl	8(%rsp), %eax
	movl	%r13d, %edx
	xorl	%esi, %esi
.L37:
	cmpl	$1, %r12d
	je	.L36
	subl	$1, %eax
	movl	%edx, 164(%rsp)
	testl	%eax, %eax
	jg	.L38
	movl	%r15d, %eax
	addl	$1, %esi
	subl	%edx, %eax
	movl	%eax, %edx
	movslq	%esi, %rax
	movl	96(%rsp,%rax,4), %eax
.L38:
	cmpl	$2, %r12d
	je	.L36
	subl	$1, %eax
	movl	%edx, 168(%rsp)
	testl	%eax, %eax
	jg	.L39
	movl	%r15d, %eax
	addl	$1, %esi
	subl	%edx, %eax
	movl	%eax, %edx
	movslq	%esi, %rax
	movl	96(%rsp,%rax,4), %eax
.L39:
	cmpl	$3, %r12d
	je	.L36
	subl	$1, %eax
	movl	%edx, 172(%rsp)
	testl	%eax, %eax
	jg	.L40
	movl	%r15d, %eax
	addl	$1, %esi
	subl	%edx, %eax
	movl	%eax, %edx
	movslq	%esi, %rax
	movl	96(%rsp,%rax,4), %eax
.L40:
	cmpl	$4, %r12d
	je	.L36
	subl	$1, %eax
	movl	%edx, 176(%rsp)
	testl	%eax, %eax
	jg	.L41
	movl	%r15d, %eax
	addl	$1, %esi
	subl	%edx, %eax
	movl	%eax, %edx
	movslq	%esi, %rax
	movl	96(%rsp,%rax,4), %eax
.L41:
	cmpl	$5, %r12d
	je	.L36
	subl	$1, %eax
	movl	%edx, 180(%rsp)
	testl	%eax, %eax
	jg	.L42
	movl	%r15d, %eax
	addl	$1, %esi
	subl	%edx, %eax
	movl	%eax, %edx
	movslq	%esi, %rax
	movl	96(%rsp,%rax,4), %eax
.L42:
	cmpl	$6, %r12d
	je	.L36
	subl	$1, %eax
	movl	%edx, 184(%rsp)
	testl	%eax, %eax
	jg	.L43
	movl	%r15d, %eax
	addl	$1, %esi
	subl	%edx, %eax
	movl	%eax, %edx
	movslq	%esi, %rax
	movl	96(%rsp,%rax,4), %eax
.L43:
	cmpl	$7, %r12d
	je	.L36
	subl	$1, %eax
	movl	%edx, 188(%rsp)
	testl	%eax, %eax
	jg	.L44
	movl	%r15d, %eax
	addl	$1, %esi
	subl	%edx, %eax
	movl	%eax, %edx
	movslq	%esi, %rax
	movl	96(%rsp,%rax,4), %eax
.L44:
	cmpl	$8, %r12d
	je	.L36
	subl	$1, %eax
	movl	%edx, 192(%rsp)
	testl	%eax, %eax
	jg	.L45
	movl	%r15d, %eax
	addl	$1, %esi
	subl	%edx, %eax
	movl	%eax, %edx
	movslq	%esi, %rax
	movl	96(%rsp,%rax,4), %eax
.L45:
	cmpl	$9, %r12d
	je	.L36
	subl	$1, %eax
	movl	%edx, 196(%rsp)
	testl	%eax, %eax
	jle	.L110
.L46:
	cmpl	$10, %r12d
	je	.L36
	subl	$1, %eax
	movl	%edx, 200(%rsp)
	testl	%eax, %eax
	jle	.L111
.L47:
	cmpl	$11, %r12d
	je	.L36
	subl	$1, %eax
	movl	%edx, 204(%rsp)
	testl	%eax, %eax
	jle	.L112
.L48:
	cmpl	$12, %r12d
	je	.L36
	subl	$1, %eax
	movl	%edx, 208(%rsp)
	testl	%eax, %eax
	jle	.L113
.L49:
	cmpl	$13, %r12d
	je	.L36
	subl	$1, %eax
	movl	%edx, 212(%rsp)
	jle	.L114
.L50:
	cmpl	$14, %r12d
	je	.L36
	movl	%edx, 216(%rsp)
.L36:
	movl	%r12d, %edx
	movq	%rbp, %rsi
	movq	%rbx, %rdi
	call	guchoku
	testl	%r14d, %r14d
	js	.L57
	cmpl	%r14d, %eax
	jl	.L57
.L51:
	subl	$1, %r13d
	jne	.L56
	movl	%r14d, %edx
	leaq	.LC2(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	xorl	%eax, %eax
	jmp	.L28
.L57:
	movl	%eax, %r14d
	jmp	.L51
.L56:
	movl	$1, %r13d
	jmp	.L53
.L109:
	movl	%r15d, %edx
	movl	12(%rsp), %eax
	movl	$1, %esi
	subl	%r13d, %edx
	jmp	.L37
.L110:
	movl	%r15d, %eax
	addl	$1, %esi
	subl	%edx, %eax
	movl	%eax, %edx
	movslq	%esi, %rax
	movl	96(%rsp,%rax,4), %eax
	jmp	.L46
.L111:
	movl	%r15d, %eax
	addl	$1, %esi
	subl	%edx, %eax
	movl	%eax, %edx
	movslq	%esi, %rax
	movl	96(%rsp,%rax,4), %eax
	jmp	.L47
.L112:
	movl	%r15d, %eax
	addl	$1, %esi
	subl	%edx, %eax
	movl	%eax, %edx
	movslq	%esi, %rax
	movl	96(%rsp,%rax,4), %eax
	jmp	.L48
.L113:
	movl	%r15d, %eax
	subl	%edx, %eax
	movl	%eax, %edx
	leal	1(%rsi), %eax
	cltq
	movl	96(%rsp,%rax,4), %eax
	jmp	.L49
.L114:
	movl	%r15d, %eax
	subl	%edx, %eax
	movl	%eax, %edx
	jmp	.L50
.L107:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE24:
	.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
	.p2align 4
	.globl	guchoku
	.type	guchoku, @function
guchoku:
.LFB23:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	pushq	%rbx
	.cfi_def_cfa_offset 24
	.cfi_offset 3, -24
	subq	$88, %rsp
	.cfi_def_cfa_offset 112
	movq	%fs:40, %rax
	movq	%rax, 72(%rsp)
	xorl	%eax, %eax
	testl	%edx, %edx
	jle	.L9
	movq	%rsp, %r8
	movl	%edx, %ebx
	movslq	%edx, %rdx
	movq	%rsi, %rbp
	salq	$2, %rdx
	movq	%rdi, %rsi
	movq	%r8, %rdi
	call	memcpy@PLT
	xorl	%edx, %edx
	xorl	%r9d, %r9d
	movq	%rax, %r8
	movq	%rax, %rcx
	jmp	.L6
	.p2align 4,,10
	.p2align 3
.L3:
	addq	$1, %rdx
	addq	$4, %rcx
	cmpl	%edx, %ebx
	jle	.L1
.L6:
	movl	0(%rbp,%rdx,4), %esi
	movl	%edx, %edi
	leal	1(%rdx), %eax
	cmpl	%esi, (%rcx)
	je	.L3
	cmpl	%eax, %ebx
	jle	.L23
	cmpl	4(%rcx), %esi
	je	.L4
	leal	2(%rdx), %eax
	cmpl	%eax, %ebx
	jle	.L23
	cmpl	8(%rcx), %esi
	je	.L4
	leal	3(%rdx), %eax
	cmpl	%eax, %ebx
	jle	.L23
	cmpl	12(%rcx), %esi
	je	.L4
	leal	4(%rdx), %eax
	cmpl	%eax, %ebx
	jle	.L23
	cmpl	16(%rcx), %esi
	je	.L4
	leal	5(%rdx), %eax
	cmpl	%eax, %ebx
	jle	.L23
	cmpl	20(%rcx), %esi
	je	.L4
	leal	6(%rdx), %eax
	cmpl	%eax, %ebx
	jle	.L23
	cmpl	24(%rcx), %esi
	je	.L4
	leal	7(%rdx), %eax
	cmpl	%eax, %ebx
	jle	.L23
	cmpl	28(%rcx), %esi
	je	.L4
	leal	8(%rdx), %eax
	cmpl	%eax, %ebx
	jle	.L23
	cmpl	32(%rcx), %esi
	je	.L4
	leal	9(%rdx), %eax
	cmpl	%eax, %ebx
	jle	.L23
	cmpl	36(%rcx), %esi
	je	.L4
	leal	10(%rdx), %eax
	cmpl	%eax, %ebx
	jle	.L23
	cmpl	40(%rcx), %esi
	je	.L4
	leal	11(%rdx), %eax
	cmpl	%eax, %ebx
	jle	.L23
	cmpl	44(%rcx), %esi
	je	.L4
	leal	12(%rdx), %eax
	cmpl	%eax, %ebx
	jle	.L23
	cmpl	48(%rcx), %esi
	je	.L4
	leal	13(%rdx), %eax
	cmpl	%eax, %ebx
	jle	.L23
	cmpl	52(%rcx), %esi
	je	.L4
	leal	14(%rdx), %eax
	cmpl	%eax, %ebx
	jle	.L23
	cmpl	56(%rcx), %esi
	je	.L4
.L23:
	movl	$235, %r9d
.L1:
	movq	72(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L27
	addq	$88, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 24
	movl	%r9d, %eax
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L4:
	.cfi_restore_state
	movl	%edx, %esi
	cmpl	%edx, %eax
	jle	.L3
	movslq	%eax, %r10
	movd	(%rsp,%r10,4), %xmm0
	leal	-1(%rax), %r10d
	movslq	%r10d, %r11
	movd	(%rsp,%r11,4), %xmm2
	movdqa	%xmm0, %xmm1
	punpckldq	%xmm2, %xmm1
	movq	%xmm1, (%r8,%r11,4)
	cmpl	%edx, %r10d
	jle	.L5
	leal	-2(%rax), %r10d
	movdqa	%xmm0, %xmm1
	movslq	%r10d, %r11
	movd	(%rsp,%r11,4), %xmm3
	punpckldq	%xmm3, %xmm1
	movq	%xmm1, (%r8,%r11,4)
	cmpl	%esi, %r10d
	jle	.L5
	leal	-3(%rax), %r10d
	movdqa	%xmm0, %xmm1
	movslq	%r10d, %r11
	movd	(%rsp,%r11,4), %xmm4
	punpckldq	%xmm4, %xmm1
	movq	%xmm1, (%r8,%r11,4)
	cmpl	%esi, %r10d
	jle	.L5
	leal	-4(%rax), %r10d
	movdqa	%xmm0, %xmm1
	movslq	%r10d, %r11
	movd	(%rsp,%r11,4), %xmm5
	punpckldq	%xmm5, %xmm1
	movq	%xmm1, (%r8,%r11,4)
	cmpl	%esi, %r10d
	jle	.L5
	leal	-5(%rax), %r10d
	movdqa	%xmm0, %xmm1
	movslq	%r10d, %r11
	movd	(%rsp,%r11,4), %xmm6
	punpckldq	%xmm6, %xmm1
	movq	%xmm1, (%r8,%r11,4)
	cmpl	%esi, %r10d
	jle	.L5
	leal	-6(%rax), %r10d
	movdqa	%xmm0, %xmm1
	movslq	%r10d, %r11
	movd	(%rsp,%r11,4), %xmm7
	punpckldq	%xmm7, %xmm1
	movq	%xmm1, (%r8,%r11,4)
	cmpl	%esi, %r10d
	jle	.L5
	leal	-7(%rax), %r10d
	movdqa	%xmm0, %xmm1
	movslq	%r10d, %r11
	movd	(%rsp,%r11,4), %xmm7
	punpckldq	%xmm7, %xmm1
	movq	%xmm1, (%r8,%r11,4)
	cmpl	%esi, %r10d
	jle	.L5
	leal	-8(%rax), %r10d
	movdqa	%xmm0, %xmm1
	movslq	%r10d, %r11
	movd	(%rsp,%r11,4), %xmm6
	punpckldq	%xmm6, %xmm1
	movq	%xmm1, (%r8,%r11,4)
	cmpl	%r10d, %esi
	jge	.L5
	leal	-9(%rax), %r10d
	movdqa	%xmm0, %xmm1
	movslq	%r10d, %r11
	movd	(%rsp,%r11,4), %xmm5
	punpckldq	%xmm5, %xmm1
	movq	%xmm1, (%r8,%r11,4)
	cmpl	%r10d, %esi
	jge	.L5
	leal	-10(%rax), %r10d
	movdqa	%xmm0, %xmm1
	movslq	%r10d, %r11
	movd	(%rsp,%r11,4), %xmm4
	punpckldq	%xmm4, %xmm1
	movq	%xmm1, (%r8,%r11,4)
	cmpl	%r10d, %esi
	jge	.L5
	leal	-11(%rax), %r10d
	movdqa	%xmm0, %xmm1
	movslq	%r10d, %r11
	movd	(%rsp,%r11,4), %xmm3
	punpckldq	%xmm3, %xmm1
	movq	%xmm1, (%r8,%r11,4)
	cmpl	%r10d, %esi
	jge	.L5
	leal	-12(%rax), %r10d
	movdqa	%xmm0, %xmm1
	movslq	%r10d, %r11
	movd	(%rsp,%r11,4), %xmm2
	punpckldq	%xmm2, %xmm1
	movq	%xmm1, (%r8,%r11,4)
	cmpl	%r10d, %esi
	jge	.L5
	leal	-13(%rax), %r10d
	movdqa	%xmm0, %xmm1
	movslq	%r10d, %r11
	movd	(%rsp,%r11,4), %xmm7
	punpckldq	%xmm7, %xmm1
	movq	%xmm1, (%r8,%r11,4)
	cmpl	%r10d, %esi
	jge	.L5
	movd	(%rsp), %xmm6
	punpckldq	%xmm6, %xmm0
	movq	%xmm0, (%rsp)
.L5:
	subl	%edi, %r9d
	addl	%eax, %r9d
	jmp	.L3
.L9:
	xorl	%r9d, %r9d
	jmp	.L1
.L27:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE23:
	.size	guchoku, .-guchoku
	.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:
.LFB24:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	leaq	.LC0(%rip), %rdi
	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
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$248, %rsp
	.cfi_def_cfa_offset 304
	movq	%fs:40, %rax
	movq	%rax, 232(%rsp)
	xorl	%eax, %eax
	leaq	28(%rsp), %rdx
	leaq	24(%rsp), %rsi
	call	__isoc99_scanf@PLT
	cmpl	$2, %eax
	jne	.L32
	cmpl	$0, 24(%rsp)
	jle	.L31
	leaq	32(%rsp), %rbx
	xorl	%ebp, %ebp
	leaq	.LC1(%rip), %r12
	jmp	.L33
	.p2align 4,,10
	.p2align 3
.L106:
	addl	$1, %ebp
	addq	$4, %rbx
	cmpl	%ebp, 24(%rsp)
	jle	.L31
.L33:
	xorl	%eax, %eax
	movq	%rbx, %rsi
	movq	%r12, %rdi
	call	__isoc99_scanf@PLT
	cmpl	$1, %eax
	je	.L106
.L32:
	movl	$1, %eax
.L28:
	movq	232(%rsp), %rdx
	subq	%fs:40, %rdx
	jne	.L107
	addq	$248, %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
.L31:
	.cfi_restore_state
	cmpl	$0, 28(%rsp)
	jle	.L34
	leaq	96(%rsp), %rbx
	xorl	%ebp, %ebp
	leaq	.LC1(%rip), %r12
	jmp	.L35
	.p2align 4,,10
	.p2align 3
.L108:
	addl	$1, %ebp
	addq	$4, %rbx
	cmpl	%ebp, 28(%rsp)
	jle	.L34
.L35:
	xorl	%eax, %eax
	movq	%rbx, %rsi
	movq	%r12, %rdi
	call	__isoc99_scanf@PLT
	cmpl	$1, %eax
	je	.L108
	jmp	.L32
.L34:
	movl	96(%rsp), %eax
	movl	24(%rsp), %r12d
	orl	$-1, %r14d
	xorl	%r13d, %r13d
	leaq	32(%rsp), %rbx
	leaq	160(%rsp), %rbp
	movl	$1, %r15d
	subl	$1, %eax
	movl	%eax, 8(%rsp)
	movl	100(%rsp), %eax
	movl	%eax, 12(%rsp)
.L53:
	testl	%r12d, %r12d
	jle	.L36
	cmpl	$0, 8(%rsp)
	movl	%r13d, 160(%rsp)
	jle	.L109
	movl	8(%rsp), %eax
	movl	%r13d, %edx
	xorl	%esi, %esi
.L37:
	cmpl	$1, %r12d
	je	.L36
	subl	$1, %eax
	movl	%edx, 164(%rsp)
	testl	%eax, %eax
	jg	.L38
	movl	%r15d, %eax
	addl	$1, %esi
	subl	%edx, %eax
	movl	%eax, %edx
	movslq	%esi, %rax
	movl	96(%rsp,%rax,4), %eax
.L38:
	cmpl	$2, %r12d
	je	.L36
	subl	$1, %eax
	movl	%edx, 168(%rsp)
	testl	%eax, %eax
	jg	.L39
	movl	%r15d, %eax
	addl	$1, %esi
	subl	%edx, %eax
	movl	%eax, %edx
	movslq	%esi, %rax
	movl	96(%rsp,%rax,4), %eax
.L39:
	cmpl	$3, %r12d
	je	.L36
	subl	$1, %eax
	movl	%edx, 172(%rsp)
	testl	%eax, %eax
	jg	.L40
	movl	%r15d, %eax
	addl	$1, %esi
	subl	%edx, %eax
	movl	%eax, %edx
	movslq	%esi, %rax
	movl	96(%rsp,%rax,4), %eax
.L40:
	cmpl	$4, %r12d
	je	.L36
	subl	$1, %eax
	movl	%edx, 176(%rsp)
	testl	%eax, %eax
	jg	.L41
	movl	%r15d, %eax
	addl	$1, %esi
	subl	%edx, %eax
	movl	%eax, %edx
	movslq	%esi, %rax
	movl	96(%rsp,%rax,4), %eax
.L41:
	cmpl	$5, %r12d
	je	.L36
	subl	$1, %eax
	movl	%edx, 180(%rsp)
	testl	%eax, %eax
	jg	.L42
	movl	%r15d, %eax
	addl	$1, %esi
	subl	%edx, %eax
	movl	%eax, %edx
	movslq	%esi, %rax
	movl	96(%rsp,%rax,4), %eax
.L42:
	cmpl	$6, %r12d
	je	.L36
	subl	$1, %eax
	movl	%edx, 184(%rsp)
	testl	%eax, %eax
	jg	.L43
	movl	%r15d, %eax
	addl	$1, %esi
	subl	%edx, %eax
	movl	%eax, %edx
	movslq	%esi, %rax
	movl	96(%rsp,%rax,4), %eax
.L43:
	cmpl	$7, %r12d
	je	.L36
	subl	$1, %eax
	movl	%edx, 188(%rsp)
	testl	%eax, %eax
	jg	.L44
	movl	%r15d, %eax
	addl	$1, %esi
	subl	%edx, %eax
	movl	%eax, %edx
	movslq	%esi, %rax
	movl	96(%rsp,%rax,4), %eax
.L44:
	cmpl	$8, %r12d
	je	.L36
	subl	$1, %eax
	movl	%edx, 192(%rsp)
	testl	%eax, %eax
	jg	.L45
	movl	%r15d, %eax
	addl	$1, %esi
	subl	%edx, %eax
	movl	%eax, %edx
	movslq	%esi, %rax
	movl	96(%rsp,%rax,4), %eax
.L45:
	cmpl	$9, %r12d
	je	.L36
	subl	$1, %eax
	movl	%edx, 196(%rsp)
	testl	%eax, %eax
	jle	.L110
.L46:
	cmpl	$10, %r12d
	je	.L36
	subl	$1, %eax
	movl	%edx, 200(%rsp)
	testl	%eax, %eax
	jle	.L111
.L47:
	cmpl	$11, %r12d
	je	.L36
	subl	$1, %eax
	movl	%edx, 204(%rsp)
	testl	%eax, %eax
	jle	.L112
.L48:
	cmpl	$12, %r12d
	je	.L36
	subl	$1, %eax
	movl	%edx, 208(%rsp)
	testl	%eax, %eax
	jle	.L113
.L49:
	cmpl	$13, %r12d
	je	.L36
	subl	$1, %eax
	movl	%edx, 212(%rsp)
	jle	.L114
.L50:
	cmpl	$14, %r12d
	je	.L36
	movl	%edx, 216(%rsp)
.L36:
	movl	%r12d, %edx
	movq	%rbp, %rsi
	movq	%rbx, %rdi
	call	guchoku
	testl	%r14d, %r14d
	js	.L57
	cmpl	%r14d, %eax
	jl	.L57
.L51:
	subl	$1, %r13d
	jne	.L56
	movl	%r14d, %edx
	leaq	.LC2(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	xorl	%eax, %eax
	jmp	.L28
.L57:
	movl	%eax, %r14d
	jmp	.L51
.L56:
	movl	$1, %r13d
	jmp	.L53
.L109:
	movl	%r15d, %edx
	movl	12(%rsp), %eax
	movl	$1, %esi
	subl	%r13d, %edx
	jmp	.L37
.L110:
	movl	%r15d, %eax
	addl	$1, %esi
	subl	%edx, %eax
	movl	%eax, %edx
	movslq	%esi, %rax
	movl	96(%rsp,%rax,4), %eax
	jmp	.L46
.L111:
	movl	%r15d, %eax
	addl	$1, %esi
	subl	%edx, %eax
	movl	%eax, %edx
	movslq	%esi, %rax
	movl	96(%rsp,%rax,4), %eax
	jmp	.L47
.L112:
	movl	%r15d, %eax
	addl	$1, %esi
	subl	%edx, %eax
	movl	%eax, %edx
	movslq	%esi, %rax
	movl	96(%rsp,%rax,4), %eax
	jmp	.L48
.L113:
	movl	%r15d, %eax
	subl	%edx, %eax
	movl	%eax, %edx
	leal	1(%rsi), %eax
	cltq
	movl	96(%rsp,%rax,4), %eax
	jmp	.L49
.L114:
	movl	%r15d, %eax
	subl	%edx, %eax
	movl	%eax, %edx
	jmp	.L50
.L107:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE24:
	.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:

#include <stdio.h>

#define MAX 15

int guchoku(const int *start, const int *goal, int num) {
	int status[MAX];
	int i, j;
	int count = 0;
	for (i = 0; i < num; i++) {
		status[i] = start[i];
	}
	for (i = 0; i < num; i++) {
		if (status[i] != goal[i]) {
			for (j = i + 1; j < num; j++) {
				if (status[j] == goal[i]) break;
			}
			if (j >= num) return MAX * MAX + 10;
			for (; j > i; j--) {
				int temp = status[j];
				status[j] = status[j - 1];
				status[j - 1] = temp;
				count++;
			}
		}
	}
	return count;
}

int main(void) {
	int N, M;
	int b[MAX];
	int p[MAX];
	int target[MAX];
	int start, current, phase, left;
	int i;
	int answer = -1, candidate;
	if (scanf("%d%d", &N, &M) != 2) return 1;
	for (i = 0; i < N; i++) {
		if (scanf("%d", &b[i]) != 1) return 1;
	}
	for (i = 0; i < M; i++) {
		if (scanf("%d", &p[i]) != 1) return 1;
	}
	for (start = 0; start <= 1; start++) {
		current = start;
		phase = 0;
		left = p[0];
		for (i = 0; i < N; i++) {
			target[i] = current;
			left--;
			if (left <= 0) {
				current = 1 - current;
				phase++;
				left = p[phase];
			}
		}
		candidate = guchoku(b, target, N);
		if (answer < 0 || candidate < answer) answer = candidate;
	}
	printf("%d\n", answer);
	return 0;
}
1 3
1 0 0 1 0 1
1 3 2
 6 3
1 0 1 0 0 1
1 3 2
 6 3
1 0 0 1 0 1
0 3 3
 6 3
0 1 0 1 0 1
0 3 3
 6 3
1 0 1 1 0 0
1 3 2
 1 3
1 0 0 1 0 1
2 3 2
 1 3
1 0 0 1 0 1
2 3 1
 1 3
1 0 0 1 0 1
2 0 1
 1 3
1 0 0 1 0 1
1 3 1
 1 3
1 0 -1 1 0 1
1 3 1

0
 2
 1
 2
 1
 0
 0
 0
 0
 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>

#define MAX 15

int guchoku(const int *start, const int *goal, int num) {
	int status[MAX];
	int i, j;
	int count = 0;
	for (i = 0; i < num; i++) {
		status[i] = start[i];
	}
	for (i = 0; i < num; i++) {
		if (status[i] != goal[i]) {
			for (j = i + 1; j < num; j++) {
				if (status[j] == goal[i]) break;
			}
			if (j >= num) return MAX * MAX + 10;
			for (; j > i; j--) {
				int temp = status[j];
				status[j] = status[j - 1];
				status[j - 1] = temp;
				count++;
			}
		}
	}
	return count;
}

int main(void) {
	int N, M;
	int b[MAX];
	int p[MAX];
	int target[MAX];
	int start, current, phase, left;
	int i;
	int answer = -1, candidate;
	if (scanf("%d%d", &N, &M) != 2) return 1;
	for (i = 0; i < N; i++) {
		if (scanf("%d", &b[i]) != 1) return 1;
	}
	for (i = 0; i < M; i++) {
		if (scanf("%d", &p[i]) != 1) return 1;
	}
	for (start = 0; start <= 1; start++) {
		current = start;
		phase = 0;
		left = p[0];
		for (i = 0; i < N; i++) {
			target[i] = current;
			left--;
			if (left <= 0) {
				current = 1 - current;
				phase++;
				left = p[phase];
			}
		}
		candidate = guchoku(b, target, N);
		if (answer < 0 || candidate < answer) answer = candidate;
	}
	printf("%d\n", answer);
	return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	guchoku
	.type	guchoku, @function
guchoku:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	addq	$-128, %rsp
	movq	%rdi, -104(%rbp)
	movq	%rsi, -112(%rbp)
	movl	%edx, -116(%rbp)
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	$0, -88(%rbp)
	movl	$0, -96(%rbp)
	jmp	.L2
.L3:
	movl	-96(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-104(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %edx
	movl	-96(%rbp), %eax
	cltq
	movl	%edx, -80(%rbp,%rax,4)
	addl	$1, -96(%rbp)
.L2:
	movl	-96(%rbp), %eax
	cmpl	-116(%rbp), %eax
	jl	.L3
	movl	$0, -96(%rbp)
	jmp	.L4
.L14:
	movl	-96(%rbp), %eax
	cltq
	movl	-80(%rbp,%rax,4), %edx
	movl	-96(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	movq	-112(%rbp), %rax
	addq	%rcx, %rax
	movl	(%rax), %eax
	cmpl	%eax, %edx
	je	.L5
	movl	-96(%rbp), %eax
	addl	$1, %eax
	movl	%eax, -92(%rbp)
	jmp	.L6
.L9:
	movl	-92(%rbp), %eax
	cltq
	movl	-80(%rbp,%rax,4), %edx
	movl	-96(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	movq	-112(%rbp), %rax
	addq	%rcx, %rax
	movl	(%rax), %eax
	cmpl	%eax, %edx
	je	.L17
	addl	$1, -92(%rbp)
.L6:
	movl	-92(%rbp), %eax
	cmpl	-116(%rbp), %eax
	jl	.L9
	jmp	.L8
.L17:
	nop
.L8:
	movl	-92(%rbp), %eax
	cmpl	-116(%rbp), %eax
	jl	.L12
	movl	$235, %eax
	jmp	.L15
.L13:
	movl	-92(%rbp), %eax
	cltq
	movl	-80(%rbp,%rax,4), %eax
	movl	%eax, -84(%rbp)
	movl	-92(%rbp), %eax
	subl	$1, %eax
	cltq
	movl	-80(%rbp,%rax,4), %edx
	movl	-92(%rbp), %eax
	cltq
	movl	%edx, -80(%rbp,%rax,4)
	movl	-92(%rbp), %eax
	subl	$1, %eax
	cltq
	movl	-84(%rbp), %edx
	movl	%edx, -80(%rbp,%rax,4)
	addl	$1, -88(%rbp)
	subl	$1, -92(%rbp)
.L12:
	movl	-92(%rbp), %eax
	cmpl	-96(%rbp), %eax
	jg	.L13
.L5:
	addl	$1, -96(%rbp)
.L4:
	movl	-96(%rbp), %eax
	cmpl	-116(%rbp), %eax
	jl	.L14
	movl	-88(%rbp), %eax
.L15:
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L16
	call	__stack_chk_fail@PLT
.L16:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	guchoku, .-guchoku
	.section	.rodata
.LC0:
	.string	"%d%d"
.LC1:
	.string	"%d"
.LC2:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB1:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$256, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	$-1, -216(%rbp)
	leaq	-240(%rbp), %rdx
	leaq	-244(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	cmpl	$2, %eax
	je	.L19
	movl	$1, %eax
	jmp	.L34
.L19:
	movl	$0, -220(%rbp)
	jmp	.L21
.L23:
	leaq	-208(%rbp), %rdx
	movl	-220(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	cmpl	$1, %eax
	je	.L22
	movl	$1, %eax
	jmp	.L34
.L22:
	addl	$1, -220(%rbp)
.L21:
	movl	-244(%rbp), %eax
	cmpl	%eax, -220(%rbp)
	jl	.L23
	movl	$0, -220(%rbp)
	jmp	.L24
.L26:
	leaq	-144(%rbp), %rdx
	movl	-220(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	cmpl	$1, %eax
	je	.L25
	movl	$1, %eax
	jmp	.L34
.L25:
	addl	$1, -220(%rbp)
.L24:
	movl	-240(%rbp), %eax
	cmpl	%eax, -220(%rbp)
	jl	.L26
	movl	$0, -236(%rbp)
	jmp	.L27
.L33:
	movl	-236(%rbp), %eax
	movl	%eax, -232(%rbp)
	movl	$0, -228(%rbp)
	movl	-144(%rbp), %eax
	movl	%eax, -224(%rbp)
	movl	$0, -220(%rbp)
	jmp	.L28
.L30:
	movl	-220(%rbp), %eax
	cltq
	movl	-232(%rbp), %edx
	movl	%edx, -80(%rbp,%rax,4)
	subl	$1, -224(%rbp)
	cmpl	$0, -224(%rbp)
	jg	.L29
	movl	$1, %eax
	subl	-232(%rbp), %eax
	movl	%eax, -232(%rbp)
	addl	$1, -228(%rbp)
	movl	-228(%rbp), %eax
	cltq
	movl	-144(%rbp,%rax,4), %eax
	movl	%eax, -224(%rbp)
.L29:
	addl	$1, -220(%rbp)
.L28:
	movl	-244(%rbp), %eax
	cmpl	%eax, -220(%rbp)
	jl	.L30
	movl	-244(%rbp), %edx
	leaq	-80(%rbp), %rcx
	leaq	-208(%rbp), %rax
	movq	%rcx, %rsi
	movq	%rax, %rdi
	call	guchoku
	movl	%eax, -212(%rbp)
	cmpl	$0, -216(%rbp)
	js	.L31
	movl	-212(%rbp), %eax
	cmpl	-216(%rbp), %eax
	jge	.L32
.L31:
	movl	-212(%rbp), %eax
	movl	%eax, -216(%rbp)
.L32:
	addl	$1, -236(%rbp)
.L27:
	cmpl	$1, -236(%rbp)
	jle	.L33
	movl	-216(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
.L34:
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L35
	call	__stack_chk_fail@PLT
.L35:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.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	guchoku
	.type	guchoku, @function
guchoku:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	addq	$-128, %rsp
	movq	%rdi, -104(%rbp)
	movq	%rsi, -112(%rbp)
	movl	%edx, -116(%rbp)
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	$0, -88(%rbp)
	movl	$0, -96(%rbp)
	jmp	.L2
.L3:
	movl	-96(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-104(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %edx
	movl	-96(%rbp), %eax
	cltq
	movl	%edx, -80(%rbp,%rax,4)
	addl	$1, -96(%rbp)
.L2:
	movl	-96(%rbp), %eax
	cmpl	-116(%rbp), %eax
	jl	.L3
	movl	$0, -96(%rbp)
	jmp	.L4
.L14:
	movl	-96(%rbp), %eax
	cltq
	movl	-80(%rbp,%rax,4), %edx
	movl	-96(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	movq	-112(%rbp), %rax
	addq	%rcx, %rax
	movl	(%rax), %eax
	cmpl	%eax, %edx
	je	.L5
	movl	-96(%rbp), %eax
	addl	$1, %eax
	movl	%eax, -92(%rbp)
	jmp	.L6
.L9:
	movl	-92(%rbp), %eax
	cltq
	movl	-80(%rbp,%rax,4), %edx
	movl	-96(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	movq	-112(%rbp), %rax
	addq	%rcx, %rax
	movl	(%rax), %eax
	cmpl	%eax, %edx
	je	.L17
	addl	$1, -92(%rbp)
.L6:
	movl	-92(%rbp), %eax
	cmpl	-116(%rbp), %eax
	jl	.L9
	jmp	.L8
.L17:
	nop
.L8:
	movl	-92(%rbp), %eax
	cmpl	-116(%rbp), %eax
	jl	.L12
	movl	$235, %eax
	jmp	.L15
.L13:
	movl	-92(%rbp), %eax
	cltq
	movl	-80(%rbp,%rax,4), %eax
	movl	%eax, -84(%rbp)
	movl	-92(%rbp), %eax
	subl	$1, %eax
	cltq
	movl	-80(%rbp,%rax,4), %edx
	movl	-92(%rbp), %eax
	cltq
	movl	%edx, -80(%rbp,%rax,4)
	movl	-92(%rbp), %eax
	subl	$1, %eax
	cltq
	movl	-84(%rbp), %edx
	movl	%edx, -80(%rbp,%rax,4)
	addl	$1, -88(%rbp)
	subl	$1, -92(%rbp)
.L12:
	movl	-92(%rbp), %eax
	cmpl	-96(%rbp), %eax
	jg	.L13
.L5:
	addl	$1, -96(%rbp)
.L4:
	movl	-96(%rbp), %eax
	cmpl	-116(%rbp), %eax
	jl	.L14
	movl	-88(%rbp), %eax
.L15:
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L16
	call	__stack_chk_fail@PLT
.L16:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	guchoku, .-guchoku
	.section	.rodata
.LC0:
	.string	"%d%d"
.LC1:
	.string	"%d"
.LC2:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB1:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$256, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	$-1, -216(%rbp)
	leaq	-240(%rbp), %rdx
	leaq	-244(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	cmpl	$2, %eax
	je	.L19
	movl	$1, %eax
	jmp	.L34
.L19:
	movl	$0, -220(%rbp)
	jmp	.L21
.L23:
	leaq	-208(%rbp), %rdx
	movl	-220(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	cmpl	$1, %eax
	je	.L22
	movl	$1, %eax
	jmp	.L34
.L22:
	addl	$1, -220(%rbp)
.L21:
	movl	-244(%rbp), %eax
	cmpl	%eax, -220(%rbp)
	jl	.L23
	movl	$0, -220(%rbp)
	jmp	.L24
.L26:
	leaq	-144(%rbp), %rdx
	movl	-220(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	cmpl	$1, %eax
	je	.L25
	movl	$1, %eax
	jmp	.L34
.L25:
	addl	$1, -220(%rbp)
.L24:
	movl	-240(%rbp), %eax
	cmpl	%eax, -220(%rbp)
	jl	.L26
	movl	$0, -236(%rbp)
	jmp	.L27
.L33:
	movl	-236(%rbp), %eax
	movl	%eax, -232(%rbp)
	movl	$0, -228(%rbp)
	movl	-144(%rbp), %eax
	movl	%eax, -224(%rbp)
	movl	$0, -220(%rbp)
	jmp	.L28
.L30:
	movl	-220(%rbp), %eax
	cltq
	movl	-232(%rbp), %edx
	movl	%edx, -80(%rbp,%rax,4)
	subl	$1, -224(%rbp)
	cmpl	$0, -224(%rbp)
	jg	.L29
	movl	$1, %eax
	subl	-232(%rbp), %eax
	movl	%eax, -232(%rbp)
	addl	$1, -228(%rbp)
	movl	-228(%rbp), %eax
	cltq
	movl	-144(%rbp,%rax,4), %eax
	movl	%eax, -224(%rbp)
.L29:
	addl	$1, -220(%rbp)
.L28:
	movl	-244(%rbp), %eax
	cmpl	%eax, -220(%rbp)
	jl	.L30
	movl	-244(%rbp), %edx
	leaq	-80(%rbp), %rcx
	leaq	-208(%rbp), %rax
	movq	%rcx, %rsi
	movq	%rax, %rdi
	call	guchoku
	movl	%eax, -212(%rbp)
	cmpl	$0, -216(%rbp)
	js	.L31
	movl	-212(%rbp), %eax
	cmpl	-216(%rbp), %eax
	jge	.L32
.L31:
	movl	-212(%rbp), %eax
	movl	%eax, -216(%rbp)
.L32:
	addl	$1, -236(%rbp)
.L27:
	cmpl	$1, -236(%rbp)
	jle	.L33
	movl	-216(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
.L34:
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L35
	call	__stack_chk_fail@PLT
.L35:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.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:
