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>

/* {1,2,3} -> ... -> {3,2,1} */
int next_permutation(int arr[],int n) {
	int target;
	int i;
	int temp;
	for (i = n - 2; i >= 0; i--) {
		if (arr[i] < arr[i + 1]) break;
	}
	if (i < 0) return 0;
	target = i;

	for (i = 0; target + i + 1 < n - i - 1; i++) {
		temp = arr[target + 1 + i];
		arr[target + 1 + i] = arr[n - 1 - i];
		arr[n - i - 1] = temp;
	}

	for (i = target + 1; i < n; i++) {
		if (arr[i] > arr[target]) break;
	}
	temp = arr[i];
	arr[i] = arr[target];
	arr[target] = temp;
	return 1;
}

int N;
char S[114514];

int count[10][10];
int cost[10][10];

int main(void) {
	int i, j;
	int bestScore = -1;
	int bestHaiti[9] = {0};
	int haiti[9] = {1, 2, 3, 4, 5, 6, 7, 8, 9};
	if (scanf("%d", &N) != 1) return 1;
	if (scanf("%114513s", S) != 1) return 1;
	for (i = 1; i < N; i++) {
		count[S[i - 1] - '0'][S[i] - '0']++;
	}
	do {
		int score;
		for (i = 0; i < 9; i++) {
			int x1 = i % 3;
			int y1 = i / 3;
			for (j = i + 1; j < 9; j++) {
				int x2 = j % 3;
				int y2 = j / 3;
				cost[haiti[i]][haiti[j]] = cost[haiti[j]][haiti[i]] = abs(x1 - x2) + abs(y1 - y2);
			}
			cost[haiti[i]][haiti[i]] = 0;
		}
		score = 0;
		for (i = 1; i <= 9; i++) {
			for (j = 1; j <= 9; j++) {
				score += count[i][j] * cost[i][j];
			}
		}
		if (bestScore < 0 || score < bestScore) {
			bestScore = score;
			for (i = 0; i < 9; i++) bestHaiti[i] = haiti[i];
		}
	} while (next_permutation(haiti, 9));
	for (i = 0; i < 3; i++) {
		printf("%d%d%d\n", bestHaiti[i * 3], bestHaiti[i * 3 + 1], bestHaiti[i * 3 + 2]);
	}
	return 0;
}

```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	next_permutation
	.type	next_permutation, @function
next_permutation:
.LFB6:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movq	%rdi, -24(%rbp)
	movl	%esi, -28(%rbp)
	movl	-28(%rbp), %eax
	subl	$2, %eax
	movl	%eax, -12(%rbp)
	jmp	.L2
.L5:
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %edx
	movl	-12(%rbp), %eax
	cltq
	addq	$1, %rax
	leaq	0(,%rax,4), %rcx
	movq	-24(%rbp), %rax
	addq	%rcx, %rax
	movl	(%rax), %eax
	cmpl	%eax, %edx
	jl	.L14
	subl	$1, -12(%rbp)
.L2:
	cmpl	$0, -12(%rbp)
	jns	.L5
	jmp	.L4
.L14:
	nop
.L4:
	cmpl	$0, -12(%rbp)
	jns	.L6
	movl	$0, %eax
	jmp	.L7
.L6:
	movl	-12(%rbp), %eax
	movl	%eax, -8(%rbp)
	movl	$0, -12(%rbp)
	jmp	.L8
.L9:
	movl	-8(%rbp), %eax
	leal	1(%rax), %edx
	movl	-12(%rbp), %eax
	addl	%edx, %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	movl	%eax, -4(%rbp)
	movl	-28(%rbp), %eax
	subl	$1, %eax
	subl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	-8(%rbp), %edx
	leal	1(%rdx), %ecx
	movl	-12(%rbp), %edx
	addl	%ecx, %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	movq	-24(%rbp), %rdx
	addq	%rcx, %rdx
	movl	(%rax), %eax
	movl	%eax, (%rdx)
	movl	-28(%rbp), %eax
	subl	-12(%rbp), %eax
	cltq
	salq	$2, %rax
	leaq	-4(%rax), %rdx
	movq	-24(%rbp), %rax
	addq	%rax, %rdx
	movl	-4(%rbp), %eax
	movl	%eax, (%rdx)
	addl	$1, -12(%rbp)
.L8:
	movl	-8(%rbp), %edx
	movl	-12(%rbp), %eax
	addl	%edx, %eax
	leal	1(%rax), %edx
	movl	-28(%rbp), %eax
	subl	-12(%rbp), %eax
	subl	$1, %eax
	cmpl	%eax, %edx
	jl	.L9
	movl	-8(%rbp), %eax
	addl	$1, %eax
	movl	%eax, -12(%rbp)
	jmp	.L10
.L13:
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %edx
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	movq	-24(%rbp), %rax
	addq	%rcx, %rax
	movl	(%rax), %eax
	cmpl	%eax, %edx
	jg	.L15
	addl	$1, -12(%rbp)
.L10:
	movl	-12(%rbp), %eax
	cmpl	-28(%rbp), %eax
	jl	.L13
	jmp	.L12
.L15:
	nop
.L12:
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	movl	%eax, -4(%rbp)
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	-12(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	movq	-24(%rbp), %rdx
	addq	%rcx, %rdx
	movl	(%rax), %eax
	movl	%eax, (%rdx)
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rax, %rdx
	movl	-4(%rbp), %eax
	movl	%eax, (%rdx)
	movl	$1, %eax
.L7:
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	next_permutation, .-next_permutation
	.globl	N
	.bss
	.align 4
	.type	N, @object
	.size	N, 4
N:
	.zero	4
	.globl	S
	.align 32
	.type	S, @object
	.size	S, 114514
S:
	.zero	114514
	.globl	count
	.align 32
	.type	count, @object
	.size	count, 400
count:
	.zero	400
	.globl	cost
	.align 32
	.type	cost, @object
	.size	cost, 400
cost:
	.zero	400
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%114513s"
.LC2:
	.string	"%d%d%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB7:
	.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	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	$-1, -120(%rbp)
	movq	$0, -96(%rbp)
	movq	$0, -88(%rbp)
	movq	$0, -80(%rbp)
	movq	$0, -72(%rbp)
	movl	$0, -64(%rbp)
	movl	$1, -48(%rbp)
	movl	$2, -44(%rbp)
	movl	$3, -40(%rbp)
	movl	$4, -36(%rbp)
	movl	$5, -32(%rbp)
	movl	$6, -28(%rbp)
	movl	$7, -24(%rbp)
	movl	$8, -20(%rbp)
	movl	$9, -16(%rbp)
	leaq	N(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	cmpl	$1, %eax
	je	.L17
	movl	$1, %eax
	jmp	.L37
.L17:
	leaq	S(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	cmpl	$1, %eax
	je	.L19
	movl	$1, %eax
	jmp	.L37
.L19:
	movl	$1, -128(%rbp)
	jmp	.L20
.L21:
	movl	-128(%rbp), %eax
	subl	$1, %eax
	cltq
	leaq	S(%rip), %rdx
	movzbl	(%rax,%rdx), %eax
	movsbl	%al, %eax
	leal	-48(%rax), %edx
	movl	-128(%rbp), %eax
	cltq
	leaq	S(%rip), %rcx
	movzbl	(%rax,%rcx), %eax
	movsbl	%al, %eax
	leal	-48(%rax), %ecx
	movslq	%ecx, %rdi
	movslq	%edx, %rsi
	movq	%rsi, %rax
	salq	$2, %rax
	addq	%rsi, %rax
	addq	%rax, %rax
	addq	%rdi, %rax
	leaq	0(,%rax,4), %rsi
	leaq	count(%rip), %rax
	movl	(%rsi,%rax), %eax
	leal	1(%rax), %esi
	movslq	%ecx, %rcx
	movslq	%edx, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rax, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	count(%rip), %rax
	movl	%esi, (%rdx,%rax)
	addl	$1, -128(%rbp)
.L20:
	movl	N(%rip), %eax
	cmpl	%eax, -128(%rbp)
	jl	.L21
.L34:
	movl	$0, -128(%rbp)
	jmp	.L22
.L25:
	movl	-128(%rbp), %eax
	movslq	%eax, %rdx
	imulq	$1431655766, %rdx, %rdx
	shrq	$32, %rdx
	movl	%eax, %esi
	sarl	$31, %esi
	movl	%edx, %ecx
	subl	%esi, %ecx
	movl	%ecx, %edx
	addl	%edx, %edx
	addl	%ecx, %edx
	subl	%edx, %eax
	movl	%eax, -112(%rbp)
	movl	-128(%rbp), %eax
	movslq	%eax, %rdx
	imulq	$1431655766, %rdx, %rdx
	shrq	$32, %rdx
	sarl	$31, %eax
	movl	%eax, %ecx
	movl	%edx, %eax
	subl	%ecx, %eax
	movl	%eax, -108(%rbp)
	movl	-128(%rbp), %eax
	addl	$1, %eax
	movl	%eax, -124(%rbp)
	jmp	.L23
.L24:
	movl	-124(%rbp), %eax
	movslq	%eax, %rdx
	imulq	$1431655766, %rdx, %rdx
	shrq	$32, %rdx
	movl	%eax, %esi
	sarl	$31, %esi
	movl	%edx, %ecx
	subl	%esi, %ecx
	movl	%ecx, %edx
	addl	%edx, %edx
	addl	%ecx, %edx
	subl	%edx, %eax
	movl	%eax, -104(%rbp)
	movl	-124(%rbp), %eax
	movslq	%eax, %rdx
	imulq	$1431655766, %rdx, %rdx
	shrq	$32, %rdx
	sarl	$31, %eax
	movl	%eax, %ecx
	movl	%edx, %eax
	subl	%ecx, %eax
	movl	%eax, -100(%rbp)
	movl	-112(%rbp), %eax
	subl	-104(%rbp), %eax
	movl	%eax, %edx
	negl	%edx
	cmovns	%edx, %eax
	movl	%eax, %edi
	movl	-108(%rbp), %eax
	subl	-100(%rbp), %eax
	movl	%eax, %edx
	negl	%edx
	cmovns	%edx, %eax
	movl	%eax, %esi
	movl	-124(%rbp), %eax
	cltq
	movl	-48(%rbp,%rax,4), %edx
	movl	-128(%rbp), %eax
	cltq
	movl	-48(%rbp,%rax,4), %ecx
	addl	%esi, %edi
	movslq	%ecx, %r8
	movslq	%edx, %rsi
	movq	%rsi, %rax
	salq	$2, %rax
	addq	%rsi, %rax
	addq	%rax, %rax
	addq	%r8, %rax
	leaq	0(,%rax,4), %rsi
	leaq	cost(%rip), %rax
	movl	%edi, (%rsi,%rax)
	movl	-128(%rbp), %eax
	cltq
	movl	-48(%rbp,%rax,4), %esi
	movl	-124(%rbp), %eax
	cltq
	movl	-48(%rbp,%rax,4), %edi
	movslq	%ecx, %rcx
	movslq	%edx, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rax, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	cost(%rip), %rax
	movl	(%rdx,%rax), %edx
	movslq	%edi, %rdi
	movslq	%esi, %rcx
	movq	%rcx, %rax
	salq	$2, %rax
	addq	%rcx, %rax
	addq	%rax, %rax
	addq	%rdi, %rax
	leaq	0(,%rax,4), %rcx
	leaq	cost(%rip), %rax
	movl	%edx, (%rcx,%rax)
	addl	$1, -124(%rbp)
.L23:
	cmpl	$8, -124(%rbp)
	jle	.L24
	movl	-128(%rbp), %eax
	cltq
	movl	-48(%rbp,%rax,4), %edx
	movl	-128(%rbp), %eax
	cltq
	movl	-48(%rbp,%rax,4), %eax
	movslq	%eax, %rcx
	movslq	%edx, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rax, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	cost(%rip), %rax
	movl	$0, (%rdx,%rax)
	addl	$1, -128(%rbp)
.L22:
	cmpl	$8, -128(%rbp)
	jle	.L25
	movl	$0, -116(%rbp)
	movl	$1, -128(%rbp)
	jmp	.L26
.L29:
	movl	$1, -124(%rbp)
	jmp	.L27
.L28:
	movl	-124(%rbp), %eax
	movslq	%eax, %rcx
	movl	-128(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rax, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	count(%rip), %rax
	movl	(%rdx,%rax), %ecx
	movl	-124(%rbp), %eax
	movslq	%eax, %rsi
	movl	-128(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rax, %rax
	addq	%rsi, %rax
	leaq	0(,%rax,4), %rdx
	leaq	cost(%rip), %rax
	movl	(%rdx,%rax), %eax
	imull	%ecx, %eax
	addl	%eax, -116(%rbp)
	addl	$1, -124(%rbp)
.L27:
	cmpl	$9, -124(%rbp)
	jle	.L28
	addl	$1, -128(%rbp)
.L26:
	cmpl	$9, -128(%rbp)
	jle	.L29
	cmpl	$0, -120(%rbp)
	js	.L30
	movl	-116(%rbp), %eax
	cmpl	-120(%rbp), %eax
	jge	.L31
.L30:
	movl	-116(%rbp), %eax
	movl	%eax, -120(%rbp)
	movl	$0, -128(%rbp)
	jmp	.L32
.L33:
	movl	-128(%rbp), %eax
	cltq
	movl	-48(%rbp,%rax,4), %edx
	movl	-128(%rbp), %eax
	cltq
	movl	%edx, -96(%rbp,%rax,4)
	addl	$1, -128(%rbp)
.L32:
	cmpl	$8, -128(%rbp)
	jle	.L33
.L31:
	leaq	-48(%rbp), %rax
	movl	$9, %esi
	movq	%rax, %rdi
	call	next_permutation
	testl	%eax, %eax
	jne	.L34
	movl	$0, -128(%rbp)
	jmp	.L35
.L36:
	movl	-128(%rbp), %edx
	movl	%edx, %eax
	addl	%eax, %eax
	addl	%edx, %eax
	addl	$2, %eax
	cltq
	movl	-96(%rbp,%rax,4), %ecx
	movl	-128(%rbp), %edx
	movl	%edx, %eax
	addl	%eax, %eax
	addl	%edx, %eax
	addl	$1, %eax
	cltq
	movl	-96(%rbp,%rax,4), %edx
	movl	-128(%rbp), %esi
	movl	%esi, %eax
	addl	%eax, %eax
	addl	%esi, %eax
	cltq
	movl	-96(%rbp,%rax,4), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	addl	$1, -128(%rbp)
.L35:
	cmpl	$2, -128(%rbp)
	jle	.L36
	movl	$0, %eax
.L37:
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L38
	call	__stack_chk_fail@PLT
.L38:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.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	next_permutation
	.type	next_permutation, @function
next_permutation:
.LFB39:
	.cfi_startproc
	endbr64
	movl	%esi, %edx
	subl	$2, %edx
	js	.L17
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	movl	%esi, %r8d
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	movslq	%esi, %r14
	leaq	0(,%r14,4), %r10
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	leaq	-8(%r10), %r13
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	leaq	(%rdi,%r13), %rax
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	movl	-4(%rdi,%r10), %r9d
	jmp	.L6
	.p2align 4,,10
	.p2align 3
.L3:
	subl	$1, %edx
	subq	$4, %rax
	cmpl	$-1, %edx
	je	.L36
.L6:
	movl	%r9d, %ecx
	movl	(%rax), %r9d
	cmpl	%ecx, %r9d
	jge	.L3
	leal	1(%rdx), %ecx
	leal	-1(%r8), %esi
	movslq	%ecx, %rbp
	cmpl	%esi, %ecx
	jge	.L5
	leal	-3(%r8), %r12d
	movslq	%ecx, %rbp
	subl	%edx, %r12d
	leaq	0(,%rbp,4), %r9
	movl	%r12d, %ebx
	shrl	%ebx
	movl	%ebx, -12(%rsp)
	addl	$1, %ebx
	movq	%rbx, %r15
	movq	%rbx, %r11
	addq	%rbp, %rbx
	negq	%r15
	salq	$2, %rbx
	leaq	(%r10,%r15,4), %r15
	cmpq	%rbx, %r15
	setge	%r15b
	cmpq	%r10, %r9
	setge	%bl
	orb	%r15b, %bl
	je	.L7
	cmpl	$1, %r12d
	jbe	.L7
	cmpl	$5, %r12d
	jbe	.L18
	leaq	-16(%rdi,%r10), %rdx
	movl	%r11d, %r10d
	addq	%rdi, %r9
	shrl	$2, %r10d
	leal	-1(%r10), %ebx
	leaq	16(%r9), %r10
	salq	$4, %rbx
	addq	%r10, %rbx
	jmp	.L9
	.p2align 4,,10
	.p2align 3
.L37:
	addq	$16, %r10
.L9:
	movdqu	(%r9), %xmm0
	movdqu	(%rdx), %xmm2
	subq	$16, %rdx
	pshufd	$27, %xmm2, %xmm1
	pshufd	$27, %xmm0, %xmm0
	movups	%xmm1, (%r9)
	movq	%r10, %r9
	movups	%xmm0, 16(%rdx)
	cmpq	%rbx, %r10
	jne	.L37
	movl	%r11d, %edx
	movl	%r8d, %r9d
	andl	$-4, %edx
	movl	%edx, %r10d
	subl	%edx, %r9d
	cmpl	%edx, %r11d
	je	.L14
.L8:
	subl	%edx, %r11d
	cmpl	%edx, -12(%rsp)
	je	.L11
	leaq	0(%rbp,%rdx), %rbx
	negq	%rdx
	leaq	0(%r13,%rdx,4), %rdx
	leaq	(%rdi,%rbx,4), %rbx
	addq	%rdi, %rdx
	movq	(%rbx), %xmm0
	movq	(%rdx), %xmm1
	pshufd	$225, %xmm0, %xmm0
	pshufd	$225, %xmm1, %xmm1
	movq	%xmm1, (%rbx)
	movq	%xmm0, (%rdx)
	movl	%r11d, %edx
	andl	$-2, %edx
	subl	%edx, %r9d
	addl	%edx, %r10d
	cmpl	%edx, %r11d
	je	.L14
.L11:
	leal	(%rcx,%r10), %edx
	subl	%r10d, %esi
	movslq	%edx, %rdx
	movslq	%esi, %rsi
	leaq	(%rdi,%rdx,4), %rdx
	movl	(%rdi,%rsi,4), %esi
	movl	(%rdx), %r11d
	movl	%esi, (%rdx)
	movslq	%r9d, %rdx
	movl	%r11d, -4(%rdi,%rdx,4)
.L14:
	movl	(%rax), %r9d
.L5:
	leaq	(%rdi,%rbp,4), %rdx
	movl	(%rdx), %esi
	cmpl	%ecx, %r8d
	jg	.L16
	jmp	.L15
	.p2align 4,,10
	.p2align 3
.L39:
	addl	$1, %ecx
	addq	$4, %rdx
	cmpl	%ecx, %r8d
	je	.L38
.L16:
	movl	(%rdx), %esi
	cmpl	%r9d, %esi
	jle	.L39
.L15:
	movl	%r9d, (%rdx)
	movl	%esi, (%rax)
	movl	$1, %eax
	popq	%rbx
	.cfi_remember_state
	.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
	.p2align 4,,10
	.p2align 3
.L36:
	.cfi_restore_state
	popq	%rbx
	.cfi_remember_state
	.cfi_def_cfa_offset 48
	xorl	%eax, %eax
	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
	.p2align 4,,10
	.p2align 3
.L38:
	.cfi_restore_state
	leaq	(%rdi,%r14,4), %rdx
	movl	(%rdx), %esi
	jmp	.L15
.L7:
	movslq	%esi, %rsi
	addq	%rdi, %r9
	leal	(%rdx,%r8), %r11d
	.p2align 4,,10
	.p2align 3
.L13:
	movl	(%r9), %edx
	movl	(%rdi,%rsi,4), %r10d
	addq	$4, %r9
	movl	%r10d, -4(%r9)
	movl	%edx, (%rdi,%rsi,4)
	subq	$1, %rsi
	movl	%r11d, %edx
	subl	%esi, %edx
	cmpl	%esi, %edx
	jl	.L13
	jmp	.L14
.L17:
	.cfi_def_cfa_offset 8
	.cfi_restore 3
	.cfi_restore 6
	.cfi_restore 12
	.cfi_restore 13
	.cfi_restore 14
	.cfi_restore 15
	xorl	%eax, %eax
	ret
.L18:
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	.cfi_offset 6, -48
	.cfi_offset 12, -40
	.cfi_offset 13, -32
	.cfi_offset 14, -24
	.cfi_offset 15, -16
	movl	%r8d, %r9d
	xorl	%edx, %edx
	xorl	%r10d, %r10d
	jmp	.L8
	.cfi_endproc
.LFE39:
	.size	next_permutation, .-next_permutation
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC2:
	.string	"%d"
.LC3:
	.string	"%114513s"
.LC4:
	.string	"%d%d%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB40:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	pxor	%xmm0, %xmm0
	leaq	N(%rip), %rsi
	leaq	.LC2(%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	$200, %rsp
	.cfi_def_cfa_offset 256
	movq	%fs:40, %rax
	movq	%rax, 184(%rsp)
	xorl	%eax, %eax
	movaps	%xmm0, 96(%rsp)
	movaps	%xmm0, 112(%rsp)
	movdqa	.LC0(%rip), %xmm0
	movl	$0, 128(%rsp)
	movaps	%xmm0, 144(%rsp)
	movdqa	.LC1(%rip), %xmm0
	movl	$9, 176(%rsp)
	movaps	%xmm0, 160(%rsp)
	call	__isoc99_scanf@PLT
	cmpl	$1, %eax
	je	.L41
.L43:
	movl	$1, %eax
.L40:
	movq	184(%rsp), %rdx
	subq	%fs:40, %rdx
	jne	.L129
	addq	$200, %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
.L41:
	.cfi_restore_state
	xorl	%eax, %eax
	leaq	S(%rip), %rsi
	leaq	.LC3(%rip), %rdi
	call	__isoc99_scanf@PLT
	subl	$1, %eax
	jne	.L43
	movl	N(%rip), %eax
	cmpl	$1, %eax
	jle	.L47
	leaq	1+S(%rip), %rdx
	leal	-2(%rax), %r8d
	movsbl	S(%rip), %esi
	leaq	1(%rdx), %rax
	leaq	count(%rip), %rdi
	addq	%rax, %r8
.L46:
	leal	-48(%rsi), %eax
	movsbl	(%rdx), %esi
	addq	$1, %rdx
	cltq
	leal	-48(%rsi), %ecx
	leaq	(%rax,%rax,4), %rax
	movslq	%ecx, %rcx
	leaq	(%rcx,%rax,2), %rax
	addl	$1, (%rdi,%rax,4)
	cmpq	%r8, %rdx
	jne	.L46
.L47:
	leaq	148(%rsp), %rax
	movb	$0, 59(%rsp)
	leaq	cost(%rip), %r12
	movl	$2863311531, %r13d
	movq	%rax, 48(%rsp)
	leaq	144(%rsp), %rax
	movl	$-1, 44(%rsp)
	movq	%rax, 32(%rsp)
.L45:
	movl	$6, 24(%rsp)
	movq	48(%rsp), %rsi
	xorl	%r10d, %r10d
	movl	$1, %r9d
	movslq	144(%rsp), %rax
	movl	$3, %ebx
	xorl	%r8d, %r8d
	movl	$5, 20(%rsp)
	movl	$4, 16(%rsp)
	movl	%eax, 40(%rsp)
	movl	$8, 28(%rsp)
	jmp	.L66
	.p2align 4,,10
	.p2align 3
.L130:
	movl	%ebp, %edi
	movl	%ebp, %r14d
	imulq	%r13, %rdi
	shrq	$33, %rdi
	leal	(%rdi,%rdi,2), %r15d
	subl	%r15d, %r14d
	movl	%r8d, %r15d
	subl	%r14d, %r15d
	movl	%r15d, %r14d
	negl	%r14d
	cmovs	%r15d, %r14d
	movl	%r10d, %r15d
	subl	%edi, %r15d
	movl	%r15d, %edi
	negl	%edi
	cmovs	%r15d, %edi
	addl	%r14d, %edi
	movslq	4(%rsi), %r14
	leaq	(%r14,%r14,4), %r15
	addq	%rdx, %r14
	leaq	(%rax,%r15,2), %r15
	movl	%edi, (%r12,%r15,4)
	movl	%edi, (%r12,%r14,4)
	cmpl	$9, %ebx
	je	.L49
	movl	%ebx, %edi
	movl	%ebx, %r14d
	imulq	%r13, %rdi
	shrq	$33, %rdi
	leal	(%rdi,%rdi,2), %r15d
	subl	%r15d, %r14d
	movl	%r8d, %r15d
	subl	%r14d, %r15d
	movl	%r15d, %r14d
	negl	%r14d
	cmovs	%r15d, %r14d
	movl	%r10d, %r15d
	subl	%edi, %r15d
	movl	%r15d, %edi
	negl	%edi
	cmovs	%r15d, %edi
	addl	%r14d, %edi
	movslq	8(%rsi), %r14
	leaq	(%r14,%r14,4), %r15
	addq	%rdx, %r14
	leaq	(%rax,%r15,2), %r15
	movl	%edi, (%r12,%r15,4)
	movl	%edi, (%r12,%r14,4)
	movl	16(%rsp), %r14d
	cmpl	$9, %r14d
	je	.L49
	movl	%r14d, %edi
	imulq	%r13, %rdi
	shrq	$33, %rdi
	leal	(%rdi,%rdi,2), %r15d
	subl	%r15d, %r14d
	movl	%r8d, %r15d
	subl	%r14d, %r15d
	movl	%r15d, %r14d
	negl	%r14d
	cmovs	%r15d, %r14d
	movl	%r10d, %r15d
	subl	%edi, %r15d
	movl	%r15d, %edi
	negl	%edi
	cmovs	%r15d, %edi
	addl	%r14d, %edi
	movslq	12(%rsi), %r14
	leaq	(%r14,%r14,4), %r15
	addq	%rdx, %r14
	leaq	(%rax,%r15,2), %r15
	movl	%edi, (%r12,%r15,4)
	movl	%edi, (%r12,%r14,4)
	movl	20(%rsp), %r14d
	cmpl	$9, %r14d
	je	.L49
	movl	%r14d, %edi
	imulq	%r13, %rdi
	shrq	$33, %rdi
	leal	(%rdi,%rdi,2), %r15d
	subl	%r15d, %r14d
	movl	%r8d, %r15d
	subl	%r14d, %r15d
	movl	%r15d, %r14d
	negl	%r14d
	cmovs	%r15d, %r14d
	movl	%r10d, %r15d
	subl	%edi, %r15d
	movl	%r15d, %edi
	negl	%edi
	cmovs	%r15d, %edi
	addl	%r14d, %edi
	movslq	16(%rsi), %r14
	leaq	(%r14,%r14,4), %r15
	addq	%rdx, %r14
	leaq	(%rax,%r15,2), %r15
	movl	%edi, (%r12,%r15,4)
	movl	24(%rsp), %r15d
	movl	%edi, (%r12,%r14,4)
	cmpl	$9, %r15d
	je	.L49
	movl	%r15d, %edi
	imulq	%r13, %rdi
	shrq	$33, %rdi
	leal	(%rdi,%rdi,2), %r14d
	movl	%r15d, %edi
	subl	%r14d, %edi
	movl	%r8d, %r14d
	subl	%edi, %r14d
	movl	%r14d, %edi
	negl	%edi
	cmovs	%r14d, %edi
	movl	$2, %r14d
	subl	%r10d, %r14d
	movslq	20(%rsi), %r10
	addl	%r14d, %edi
	leaq	(%r10,%r10,4), %r15
	addq	%rdx, %r10
	leaq	(%rax,%r15,2), %r15
	movl	%edi, (%r12,%r15,4)
	movl	%edi, (%r12,%r10,4)
	leal	6(%r9), %edi
	cmpl	$3, %r9d
	je	.L49
	movl	%edi, %r9d
	imulq	%r13, %r9
	shrq	$33, %r9
	leal	(%r9,%r9,2), %r9d
	subl	%r9d, %edi
	movl	%r8d, %r9d
	subl	%edi, %r9d
	movl	%r9d, %edi
	negl	%edi
	cmovs	%r9d, %edi
	movslq	24(%rsi), %r9
	leaq	(%r9,%r9,4), %r10
	addl	%r14d, %edi
	addq	%rdx, %r9
	cmpl	$9, 28(%rsp)
	leaq	(%rax,%r10,2), %r10
	movl	%edi, (%r12,%r10,4)
	movl	%edi, (%r12,%r9,4)
	je	.L49
	movl	$2, %edi
	subl	%r8d, %edi
	leal	(%rdi,%r14), %r8d
	movslq	28(%rsi), %rdi
	leaq	(%rdi,%rdi,4), %r9
	addq	%rdx, %rdi
	leaq	(%rax,%r9,2), %r9
	movl	%r8d, (%r12,%r9,4)
	movl	%r8d, (%r12,%rdi,4)
.L49:
	leaq	(%rax,%rax,4), %rdx
	addl	$1, 28(%rsp)
	addq	$4, %rsi
	addl	$1, %ebx
	addl	$1, 16(%rsp)
	leaq	(%rax,%rdx,2), %rax
	movl	%ebp, %r9d
	movl	%r11d, %r10d
	addl	$1, 20(%rsp)
	movl	%ecx, %r8d
	addl	$1, 24(%rsp)
	movl	$0, (%r12,%rax,4)
	movslq	12(%rsp), %rax
.L66:
	movl	%r9d, %ecx
	movl	%r10d, %ebp
	movslq	(%rsi), %r15
	imulq	%r13, %rcx
	leaq	(%r15,%r15,4), %r14
	movl	%r15d, 12(%rsp)
	shrq	$33, %rcx
	leal	(%rcx,%rcx,2), %edx
	movl	%ecx, %r11d
	movl	%r9d, %ecx
	subl	%edx, %ecx
	movl	%r8d, %edx
	subl	%ecx, %edx
	movl	%edx, %edi
	negl	%edi
	cmovs	%edx, %edi
	subl	%r11d, %ebp
	movl	%ebp, %edx
	negl	%edx
	cmovs	%ebp, %edx
	addq	%r14, %r14
	addl	%edx, %edi
	leaq	(%r14,%rax), %rdx
	movl	%edi, (%r12,%rdx,4)
	leaq	(%rax,%rax,4), %rdx
	addq	%rdx, %rdx
	leaq	(%rdx,%r15), %rbp
	movl	%edi, (%r12,%rbp,4)
	leal	1(%r9), %ebp
	cmpl	$8, %r9d
	jne	.L130
	addq	%rax, %rdx
	addq	%r15, %r14
	leaq	44+cost(%rip), %rcx
	xorl	%eax, %eax
	movl	$0, (%r12,%rdx,4)
	leaq	44+count(%rip), %rdx
	movl	$0, (%r12,%r14,4)
	.p2align 4,,10
	.p2align 3
.L50:
	movl	(%rdx), %esi
	imull	(%rcx), %esi
	addq	$40, %rdx
	addq	$40, %rcx
	leaq	404+count(%rip), %rbx
	addl	%esi, %eax
	movl	-36(%rdx), %esi
	imull	-36(%rcx), %esi
	addl	%eax, %esi
	movl	-32(%rdx), %eax
	imull	-32(%rcx), %eax
	addl	%esi, %eax
	movl	-28(%rdx), %esi
	imull	-28(%rcx), %esi
	addl	%eax, %esi
	movl	-24(%rdx), %eax
	imull	-24(%rcx), %eax
	addl	%esi, %eax
	movl	-20(%rdx), %esi
	imull	-20(%rcx), %esi
	addl	%eax, %esi
	movl	-16(%rdx), %eax
	imull	-16(%rcx), %eax
	addl	%esi, %eax
	movl	-12(%rdx), %esi
	imull	-12(%rcx), %esi
	addl	%eax, %esi
	movl	-8(%rdx), %eax
	imull	-8(%rcx), %eax
	addl	%esi, %eax
	cmpq	%rdx, %rbx
	jne	.L50
	movl	44(%rsp), %ebx
	movl	172(%rsp), %ecx
	movl	176(%rsp), %edi
	movl	%ebx, %esi
	shrl	$31, %esi
	cmpl	%eax, %ebx
	setg	%dl
	orb	%sil, %dl
	jne	.L131
.L51:
	cmpl	%edi, %ecx
	jl	.L52
	movl	168(%rsp), %eax
	cmpl	%ecx, %eax
	jl	.L70
	movl	164(%rsp), %edx
	cmpl	%edx, %eax
	jg	.L71
	movl	160(%rsp), %eax
	cmpl	%eax, %edx
	jg	.L72
	movl	156(%rsp), %edx
	cmpl	%edx, %eax
	jg	.L73
	movl	152(%rsp), %eax
	cmpl	%eax, %edx
	jg	.L74
	movl	148(%rsp), %edx
	cmpl	%edx, %eax
	jg	.L75
	cmpl	40(%rsp), %edx
	jg	.L132
	cmpb	$0, 59(%rsp)
	je	.L60
	movl	80(%rsp), %eax
	movl	%eax, 128(%rsp)
	movl	88(%rsp), %eax
	movl	%eax, 124(%rsp)
	movl	76(%rsp), %eax
	movl	%eax, 120(%rsp)
	movl	60(%rsp), %eax
	movl	%eax, 116(%rsp)
	movl	84(%rsp), %eax
	movl	%eax, 112(%rsp)
	movl	64(%rsp), %eax
	movl	%eax, 108(%rsp)
	movl	92(%rsp), %eax
	movl	%eax, 104(%rsp)
	movl	68(%rsp), %eax
	movl	%eax, 100(%rsp)
	movl	72(%rsp), %eax
	movl	%eax, 96(%rsp)
.L60:
	leaq	96(%rsp), %rbx
	leaq	132(%rsp), %r12
	leaq	.LC4(%rip), %rbp
.L61:
	movl	4(%rbx), %ecx
	movl	8(%rbx), %r8d
	movq	%rbp, %rsi
	movl	$1, %edi
	movl	(%rbx), %edx
	xorl	%eax, %eax
	addq	$12, %rbx
	call	__printf_chk@PLT
	cmpq	%rbx, %r12
	jne	.L61
	xorl	%eax, %eax
	jmp	.L40
.L132:
	movdqu	148(%rsp), %xmm0
	movl	$1, %edx
	xorl	%ecx, %ecx
	movl	$1, %r8d
	movdqu	164(%rsp), %xmm2
	pshufd	$27, %xmm0, %xmm0
	pshufd	$27, %xmm2, %xmm1
	movups	%xmm0, 164(%rsp)
	movups	%xmm1, 148(%rsp)
	.p2align 4,,10
	.p2align 3
.L62:
	movq	32(%rsp), %rax
	leaq	0(,%r8,4), %rsi
	leaq	(%rax,%rcx,4), %rdi
	movl	(%rdi), %ecx
	cmpl	%ecx, 144(%rsp,%r8,4)
	jg	.L67
	leal	1(%rdx), %eax
	cmpl	%ecx, 148(%rsp,%rsi)
	jg	.L58
	leal	2(%rdx), %eax
	cmpl	$7, %edx
	je	.L58
	cmpl	%ecx, 152(%rsp,%rsi)
	jg	.L58
	leal	3(%rdx), %eax
	cmpl	$6, %edx
	je	.L58
	cmpl	156(%rsp,%rsi), %ecx
	jl	.L58
	leal	4(%rdx), %eax
	cmpl	$5, %edx
	je	.L58
	cmpl	160(%rsp,%rsi), %ecx
	jl	.L58
	leal	5(%rdx), %eax
	cmpl	$4, %edx
	je	.L58
	cmpl	164(%rsp,%rsi), %ecx
	jl	.L58
	leal	6(%rdx), %eax
	cmpl	$3, %edx
	je	.L58
	cmpl	168(%rsp,%rsi), %ecx
	jl	.L58
	cmpl	$2, %edx
	je	.L76
	xorl	%eax, %eax
	cmpl	%ecx, 176(%rsp)
	setle	%al
	addl	$8, %eax
.L58:
	movq	32(%rsp), %rbx
	cltq
	leaq	(%rbx,%rax,4), %rax
	movl	(%rax), %edx
	movl	%ecx, (%rax)
	movl	%edx, (%rdi)
	jmp	.L45
.L131:
	movl	148(%rsp), %ebx
	movl	%edi, 80(%rsp)
	movl	%ecx, 88(%rsp)
	movl	%ebx, 68(%rsp)
	movl	152(%rsp), %ebx
	movb	%dl, 59(%rsp)
	movl	%ebx, 92(%rsp)
	movl	156(%rsp), %ebx
	movl	%eax, 44(%rsp)
	movl	%ebx, 64(%rsp)
	movl	160(%rsp), %ebx
	movl	%ebx, 84(%rsp)
	movl	164(%rsp), %ebx
	movl	%ebx, 60(%rsp)
	movl	168(%rsp), %ebx
	movl	%ebx, 76(%rsp)
	movl	40(%rsp), %ebx
	movl	%ebx, 72(%rsp)
	jmp	.L51
.L52:
	movl	172(%rsp), %ecx
	leaq	172(%rsp), %rdi
	cmpl	176(%rsp), %ecx
	jl	.L133
.L76:
	movl	$9, %eax
	jmp	.L58
.L70:
	movl	$6, %ecx
.L53:
	movq	32(%rsp), %rax
	leal	1(%rcx), %edx
	movslq	%edx, %r8
	leaq	(%rax,%r8,4), %rax
	movl	(%rax), %esi
	movl	%edi, (%rax)
	movl	%esi, 176(%rsp)
	jmp	.L62
.L133:
	movl	$8, %edx
.L67:
	movl	%edx, %eax
	jmp	.L58
.L74:
	movl	$2, %ecx
.L54:
	movq	172(%rsp), %xmm1
	movq	32(%rsp), %rax
	leal	1(%rcx), %edx
	movslq	%edx, %r8
	leaq	(%rax,%r8,4), %rax
	pshufd	$225, %xmm1, %xmm1
	movq	(%rax), %xmm0
	movq	%xmm1, (%rax)
	movl	$6, %eax
	subl	%ecx, %eax
	pshufd	$225, %xmm0, %xmm0
	shrl	%eax
	movq	%xmm0, 172(%rsp)
	cmpl	$1, %eax
	je	.L62
	movq	32(%rsp), %rbx
	leal	3(%rcx), %eax
	movl	168(%rsp), %edi
	cltq
	leaq	(%rbx,%rax,4), %rax
	movl	(%rax), %esi
	movl	%edi, (%rax)
	movl	%esi, 168(%rsp)
	jmp	.L62
.L73:
	movl	$3, %ecx
	jmp	.L54
.L72:
	movl	$4, %ecx
	jmp	.L54
.L71:
	movl	$5, %ecx
	jmp	.L53
.L75:
	movl	$1, %ecx
	jmp	.L54
.L129:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE40:
	.size	main, .-main
	.globl	cost
	.bss
	.align 32
	.type	cost, @object
	.size	cost, 400
cost:
	.zero	400
	.globl	count
	.align 32
	.type	count, @object
	.size	count, 400
count:
	.zero	400
	.globl	S
	.align 32
	.type	S, @object
	.size	S, 114514
S:
	.zero	114514
	.globl	N
	.align 4
	.type	N, @object
	.size	N, 4
N:
	.zero	4
	.section	.rodata.cst16,"aM",@progbits,16
	.align 16
.LC0:
	.long	1
	.long	2
	.long	3
	.long	4
	.align 16
.LC1:
	.long	5
	.long	6
	.long	7
	.long	8
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:

rule
	.file	"temp.c"
	.text
	.p2align 4
	.globl	next_permutation
	.type	next_permutation, @function
next_permutation:
.LFB39:
	.cfi_startproc
	endbr64
	movl	%esi, %edx
	subl	$2, %edx
	js	.L17
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	movl	%esi, %r8d
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	movslq	%esi, %r14
	leaq	0(,%r14,4), %r10
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	leaq	-8(%r10), %r13
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	leaq	(%rdi,%r13), %rax
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	movl	-4(%rdi,%r10), %r9d
	jmp	.L6
	.p2align 4,,10
	.p2align 3
.L3:
	subl	$1, %edx
	subq	$4, %rax
	cmpl	$-1, %edx
	je	.L36
.L6:
	movl	%r9d, %ecx
	movl	(%rax), %r9d
	cmpl	%ecx, %r9d
	jge	.L3
	leal	1(%rdx), %ecx
	leal	-1(%r8), %esi
	movslq	%ecx, %rbp
	cmpl	%esi, %ecx
	jge	.L5
	leal	-3(%r8), %r12d
	movslq	%ecx, %rbp
	subl	%edx, %r12d
	leaq	0(,%rbp,4), %r9
	movl	%r12d, %ebx
	shrl	%ebx
	movl	%ebx, -12(%rsp)
	addl	$1, %ebx
	movq	%rbx, %r15
	movq	%rbx, %r11
	addq	%rbp, %rbx
	negq	%r15
	salq	$2, %rbx
	leaq	(%r10,%r15,4), %r15
	cmpq	%rbx, %r15
	setge	%r15b
	cmpq	%r10, %r9
	setge	%bl
	orb	%r15b, %bl
	je	.L7
	cmpl	$1, %r12d
	jbe	.L7
	cmpl	$5, %r12d
	jbe	.L18
	leaq	-16(%rdi,%r10), %rdx
	movl	%r11d, %r10d
	addq	%rdi, %r9
	shrl	$2, %r10d
	leal	-1(%r10), %ebx
	leaq	16(%r9), %r10
	salq	$4, %rbx
	addq	%r10, %rbx
	jmp	.L9
	.p2align 4,,10
	.p2align 3
.L37:
	addq	$16, %r10
.L9:
	movdqu	(%r9), %xmm0
	movdqu	(%rdx), %xmm2
	subq	$16, %rdx
	pshufd	$27, %xmm2, %xmm1
	pshufd	$27, %xmm0, %xmm0
	movups	%xmm1, (%r9)
	movq	%r10, %r9
	movups	%xmm0, 16(%rdx)
	cmpq	%rbx, %r10
	jne	.L37
	movl	%r11d, %edx
	movl	%r8d, %r9d
	andl	$-4, %edx
	movl	%edx, %r10d
	subl	%edx, %r9d
	cmpl	%edx, %r11d
	je	.L14
.L8:
	subl	%edx, %r11d
	cmpl	%edx, -12(%rsp)
	je	.L11
	leaq	0(%rbp,%rdx), %rbx
	negq	%rdx
	leaq	0(%r13,%rdx,4), %rdx
	leaq	(%rdi,%rbx,4), %rbx
	addq	%rdi, %rdx
	movq	(%rbx), %xmm0
	movq	(%rdx), %xmm1
	pshufd	$225, %xmm0, %xmm0
	pshufd	$225, %xmm1, %xmm1
	movq	%xmm1, (%rbx)
	movq	%xmm0, (%rdx)
	movl	%r11d, %edx
	andl	$-2, %edx
	subl	%edx, %r9d
	addl	%edx, %r10d
	cmpl	%edx, %r11d
	je	.L14
.L11:
	leal	(%rcx,%r10), %edx
	subl	%r10d, %esi
	movslq	%edx, %rdx
	movslq	%esi, %rsi
	leaq	(%rdi,%rdx,4), %rdx
	movl	(%rdi,%rsi,4), %esi
	movl	(%rdx), %r11d
	movl	%esi, (%rdx)
	movslq	%r9d, %rdx
	movl	%r11d, -4(%rdi,%rdx,4)
.L14:
	movl	(%rax), %r9d
.L5:
	leaq	(%rdi,%rbp,4), %rdx
	movl	(%rdx), %esi
	cmpl	%ecx, %r8d
	jg	.L16
	jmp	.L15
	.p2align 4,,10
	.p2align 3
.L39:
	addl	$1, %ecx
	addq	$4, %rdx
	cmpl	%ecx, %r8d
	je	.L38
.L16:
	movl	(%rdx), %esi
	cmpl	%r9d, %esi
	jle	.L39
.L15:
	movl	%r9d, (%rdx)
	movl	%esi, (%rax)
	movl	$1, %eax
	popq	%rbx
	.cfi_remember_state
	.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
	.p2align 4,,10
	.p2align 3
.L36:
	.cfi_restore_state
	popq	%rbx
	.cfi_remember_state
	.cfi_def_cfa_offset 48
	xorl	%eax, %eax
	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
	.p2align 4,,10
	.p2align 3
.L38:
	.cfi_restore_state
	leaq	(%rdi,%r14,4), %rdx
	movl	(%rdx), %esi
	jmp	.L15
.L7:
	movslq	%esi, %rsi
	addq	%rdi, %r9
	leal	(%rdx,%r8), %r11d
	.p2align 4,,10
	.p2align 3
.L13:
	movl	(%r9), %edx
	movl	(%rdi,%rsi,4), %r10d
	addq	$4, %r9
	movl	%r10d, -4(%r9)
	movl	%edx, (%rdi,%rsi,4)
	subq	$1, %rsi
	movl	%r11d, %edx
	subl	%esi, %edx
	cmpl	%esi, %edx
	jl	.L13
	jmp	.L14
.L17:
	.cfi_def_cfa_offset 8
	.cfi_restore 3
	.cfi_restore 6
	.cfi_restore 12
	.cfi_restore 13
	.cfi_restore 14
	.cfi_restore 15
	xorl	%eax, %eax
	ret
.L18:
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	.cfi_offset 6, -48
	.cfi_offset 12, -40
	.cfi_offset 13, -32
	.cfi_offset 14, -24
	.cfi_offset 15, -16
	movl	%r8d, %r9d
	xorl	%edx, %edx
	xorl	%r10d, %r10d
	jmp	.L8
	.cfi_endproc
.LFE39:
	.size	next_permutation, .-next_permutation
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC2:
	.string	"%d"
.LC3:
	.string	"%114513s"
.LC4:
	.string	"%d%d%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB40:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	pxor	%xmm0, %xmm0
	leaq	N(%rip), %rsi
	leaq	.LC2(%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	$200, %rsp
	.cfi_def_cfa_offset 256
	movq	%fs:40, %rax
	movq	%rax, 184(%rsp)
	xorl	%eax, %eax
	movaps	%xmm0, 96(%rsp)
	movaps	%xmm0, 112(%rsp)
	movdqa	.LC0(%rip), %xmm0
	movl	$0, 128(%rsp)
	movaps	%xmm0, 144(%rsp)
	movdqa	.LC1(%rip), %xmm0
	movl	$9, 176(%rsp)
	movaps	%xmm0, 160(%rsp)
	call	__isoc99_scanf@PLT
	cmpl	$1, %eax
	je	.L41
.L43:
	movl	$1, %eax
.L40:
	movq	184(%rsp), %rdx
	subq	%fs:40, %rdx
	jne	.L129
	addq	$200, %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
.L41:
	.cfi_restore_state
	xorl	%eax, %eax
	leaq	S(%rip), %rsi
	leaq	.LC3(%rip), %rdi
	call	__isoc99_scanf@PLT
	subl	$1, %eax
	jne	.L43
	movl	N(%rip), %eax
	cmpl	$1, %eax
	jle	.L47
	leaq	1+S(%rip), %rdx
	leal	-2(%rax), %r8d
	movsbl	S(%rip), %esi
	leaq	1(%rdx), %rax
	leaq	count(%rip), %rdi
	addq	%rax, %r8
.L46:
	leal	-48(%rsi), %eax
	movsbl	(%rdx), %esi
	addq	$1, %rdx
	cltq
	leal	-48(%rsi), %ecx
	leaq	(%rax,%rax,4), %rax
	movslq	%ecx, %rcx
	leaq	(%rcx,%rax,2), %rax
	addl	$1, (%rdi,%rax,4)
	cmpq	%r8, %rdx
	jne	.L46
.L47:
	leaq	148(%rsp), %rax
	movb	$0, 59(%rsp)
	leaq	cost(%rip), %r12
	movl	$2863311531, %r13d
	movq	%rax, 48(%rsp)
	leaq	144(%rsp), %rax
	movl	$-1, 44(%rsp)
	movq	%rax, 32(%rsp)
.L45:
	movl	$6, 24(%rsp)
	movq	48(%rsp), %rsi
	xorl	%r10d, %r10d
	movl	$1, %r9d
	movslq	144(%rsp), %rax
	movl	$3, %ebx
	xorl	%r8d, %r8d
	movl	$5, 20(%rsp)
	movl	$4, 16(%rsp)
	movl	%eax, 40(%rsp)
	movl	$8, 28(%rsp)
	jmp	.L66
	.p2align 4,,10
	.p2align 3
.L130:
	movl	%ebp, %edi
	movl	%ebp, %r14d
	imulq	%r13, %rdi
	shrq	$33, %rdi
	leal	(%rdi,%rdi,2), %r15d
	subl	%r15d, %r14d
	movl	%r8d, %r15d
	subl	%r14d, %r15d
	movl	%r15d, %r14d
	negl	%r14d
	cmovs	%r15d, %r14d
	movl	%r10d, %r15d
	subl	%edi, %r15d
	movl	%r15d, %edi
	negl	%edi
	cmovs	%r15d, %edi
	addl	%r14d, %edi
	movslq	4(%rsi), %r14
	leaq	(%r14,%r14,4), %r15
	addq	%rdx, %r14
	leaq	(%rax,%r15,2), %r15
	movl	%edi, (%r12,%r15,4)
	movl	%edi, (%r12,%r14,4)
	cmpl	$9, %ebx
	je	.L49
	movl	%ebx, %edi
	movl	%ebx, %r14d
	imulq	%r13, %rdi
	shrq	$33, %rdi
	leal	(%rdi,%rdi,2), %r15d
	subl	%r15d, %r14d
	movl	%r8d, %r15d
	subl	%r14d, %r15d
	movl	%r15d, %r14d
	negl	%r14d
	cmovs	%r15d, %r14d
	movl	%r10d, %r15d
	subl	%edi, %r15d
	movl	%r15d, %edi
	negl	%edi
	cmovs	%r15d, %edi
	addl	%r14d, %edi
	movslq	8(%rsi), %r14
	leaq	(%r14,%r14,4), %r15
	addq	%rdx, %r14
	leaq	(%rax,%r15,2), %r15
	movl	%edi, (%r12,%r15,4)
	movl	%edi, (%r12,%r14,4)
	movl	16(%rsp), %r14d
	cmpl	$9, %r14d
	je	.L49
	movl	%r14d, %edi
	imulq	%r13, %rdi
	shrq	$33, %rdi
	leal	(%rdi,%rdi,2), %r15d
	subl	%r15d, %r14d
	movl	%r8d, %r15d
	subl	%r14d, %r15d
	movl	%r15d, %r14d
	negl	%r14d
	cmovs	%r15d, %r14d
	movl	%r10d, %r15d
	subl	%edi, %r15d
	movl	%r15d, %edi
	negl	%edi
	cmovs	%r15d, %edi
	addl	%r14d, %edi
	movslq	12(%rsi), %r14
	leaq	(%r14,%r14,4), %r15
	addq	%rdx, %r14
	leaq	(%rax,%r15,2), %r15
	movl	%edi, (%r12,%r15,4)
	movl	%edi, (%r12,%r14,4)
	movl	20(%rsp), %r14d
	cmpl	$9, %r14d
	je	.L49
	movl	%r14d, %edi
	imulq	%r13, %rdi
	shrq	$33, %rdi
	leal	(%rdi,%rdi,2), %r15d
	subl	%r15d, %r14d
	movl	%r8d, %r15d
	subl	%r14d, %r15d
	movl	%r15d, %r14d
	negl	%r14d
	cmovs	%r15d, %r14d
	movl	%r10d, %r15d
	subl	%edi, %r15d
	movl	%r15d, %edi
	negl	%edi
	cmovs	%r15d, %edi
	addl	%r14d, %edi
	movslq	16(%rsi), %r14
	leaq	(%r14,%r14,4), %r15
	addq	%rdx, %r14
	leaq	(%rax,%r15,2), %r15
	movl	%edi, (%r12,%r15,4)
	movl	24(%rsp), %r15d
	movl	%edi, (%r12,%r14,4)
	cmpl	$9, %r15d
	je	.L49
	movl	%r15d, %edi
	imulq	%r13, %rdi
	shrq	$33, %rdi
	leal	(%rdi,%rdi,2), %r14d
	movl	%r15d, %edi
	subl	%r14d, %edi
	movl	%r8d, %r14d
	subl	%edi, %r14d
	movl	%r14d, %edi
	negl	%edi
	cmovs	%r14d, %edi
	movl	$2, %r14d
	subl	%r10d, %r14d
	movslq	20(%rsi), %r10
	addl	%r14d, %edi
	leaq	(%r10,%r10,4), %r15
	addq	%rdx, %r10
	leaq	(%rax,%r15,2), %r15
	movl	%edi, (%r12,%r15,4)
	movl	%edi, (%r12,%r10,4)
	leal	6(%r9), %edi
	cmpl	$3, %r9d
	je	.L49
	movl	%edi, %r9d
	imulq	%r13, %r9
	shrq	$33, %r9
	leal	(%r9,%r9,2), %r9d
	subl	%r9d, %edi
	movl	%r8d, %r9d
	subl	%edi, %r9d
	movl	%r9d, %edi
	negl	%edi
	cmovs	%r9d, %edi
	movslq	24(%rsi), %r9
	leaq	(%r9,%r9,4), %r10
	addl	%r14d, %edi
	addq	%rdx, %r9
	cmpl	$9, 28(%rsp)
	leaq	(%rax,%r10,2), %r10
	movl	%edi, (%r12,%r10,4)
	movl	%edi, (%r12,%r9,4)
	je	.L49
	movl	$2, %edi
	subl	%r8d, %edi
	leal	(%rdi,%r14), %r8d
	movslq	28(%rsi), %rdi
	leaq	(%rdi,%rdi,4), %r9
	addq	%rdx, %rdi
	leaq	(%rax,%r9,2), %r9
	movl	%r8d, (%r12,%r9,4)
	movl	%r8d, (%r12,%rdi,4)
.L49:
	leaq	(%rax,%rax,4), %rdx
	addl	$1, 28(%rsp)
	addq	$4, %rsi
	addl	$1, %ebx
	addl	$1, 16(%rsp)
	leaq	(%rax,%rdx,2), %rax
	movl	%ebp, %r9d
	movl	%r11d, %r10d
	addl	$1, 20(%rsp)
	movl	%ecx, %r8d
	addl	$1, 24(%rsp)
	movl	$0, (%r12,%rax,4)
	movslq	12(%rsp), %rax
.L66:
	movl	%r9d, %ecx
	movl	%r10d, %ebp
	movslq	(%rsi), %r15
	imulq	%r13, %rcx
	leaq	(%r15,%r15,4), %r14
	movl	%r15d, 12(%rsp)
	shrq	$33, %rcx
	leal	(%rcx,%rcx,2), %edx
	movl	%ecx, %r11d
	movl	%r9d, %ecx
	subl	%edx, %ecx
	movl	%r8d, %edx
	subl	%ecx, %edx
	movl	%edx, %edi
	negl	%edi
	cmovs	%edx, %edi
	subl	%r11d, %ebp
	movl	%ebp, %edx
	negl	%edx
	cmovs	%ebp, %edx
	addq	%r14, %r14
	addl	%edx, %edi
	leaq	(%r14,%rax), %rdx
	movl	%edi, (%r12,%rdx,4)
	leaq	(%rax,%rax,4), %rdx
	addq	%rdx, %rdx
	leaq	(%rdx,%r15), %rbp
	movl	%edi, (%r12,%rbp,4)
	leal	1(%r9), %ebp
	cmpl	$8, %r9d
	jne	.L130
	addq	%rax, %rdx
	addq	%r15, %r14
	leaq	44+cost(%rip), %rcx
	xorl	%eax, %eax
	movl	$0, (%r12,%rdx,4)
	leaq	44+count(%rip), %rdx
	movl	$0, (%r12,%r14,4)
	.p2align 4,,10
	.p2align 3
.L50:
	movl	(%rdx), %esi
	imull	(%rcx), %esi
	addq	$40, %rdx
	addq	$40, %rcx
	leaq	404+count(%rip), %rbx
	addl	%esi, %eax
	movl	-36(%rdx), %esi
	imull	-36(%rcx), %esi
	addl	%eax, %esi
	movl	-32(%rdx), %eax
	imull	-32(%rcx), %eax
	addl	%esi, %eax
	movl	-28(%rdx), %esi
	imull	-28(%rcx), %esi
	addl	%eax, %esi
	movl	-24(%rdx), %eax
	imull	-24(%rcx), %eax
	addl	%esi, %eax
	movl	-20(%rdx), %esi
	imull	-20(%rcx), %esi
	addl	%eax, %esi
	movl	-16(%rdx), %eax
	imull	-16(%rcx), %eax
	addl	%esi, %eax
	movl	-12(%rdx), %esi
	imull	-12(%rcx), %esi
	addl	%eax, %esi
	movl	-8(%rdx), %eax
	imull	-8(%rcx), %eax
	addl	%esi, %eax
	cmpq	%rdx, %rbx
	jne	.L50
	movl	44(%rsp), %ebx
	movl	172(%rsp), %ecx
	movl	176(%rsp), %edi
	movl	%ebx, %esi
	shrl	$31, %esi
	cmpl	%eax, %ebx
	setg	%dl
	orb	%sil, %dl
	jne	.L131
.L51:
	cmpl	%edi, %ecx
	jl	.L52
	movl	168(%rsp), %eax
	cmpl	%ecx, %eax
	jl	.L70
	movl	164(%rsp), %edx
	cmpl	%edx, %eax
	jg	.L71
	movl	160(%rsp), %eax
	cmpl	%eax, %edx
	jg	.L72
	movl	156(%rsp), %edx
	cmpl	%edx, %eax
	jg	.L73
	movl	152(%rsp), %eax
	cmpl	%eax, %edx
	jg	.L74
	movl	148(%rsp), %edx
	cmpl	%edx, %eax
	jg	.L75
	cmpl	40(%rsp), %edx
	jg	.L132
	cmpb	$0, 59(%rsp)
	je	.L60
	movl	80(%rsp), %eax
	movl	%eax, 128(%rsp)
	movl	88(%rsp), %eax
	movl	%eax, 124(%rsp)
	movl	76(%rsp), %eax
	movl	%eax, 120(%rsp)
	movl	60(%rsp), %eax
	movl	%eax, 116(%rsp)
	movl	84(%rsp), %eax
	movl	%eax, 112(%rsp)
	movl	64(%rsp), %eax
	movl	%eax, 108(%rsp)
	movl	92(%rsp), %eax
	movl	%eax, 104(%rsp)
	movl	68(%rsp), %eax
	movl	%eax, 100(%rsp)
	movl	72(%rsp), %eax
	movl	%eax, 96(%rsp)
.L60:
	leaq	96(%rsp), %rbx
	leaq	132(%rsp), %r12
	leaq	.LC4(%rip), %rbp
.L61:
	movl	4(%rbx), %ecx
	movl	8(%rbx), %r8d
	movq	%rbp, %rsi
	movl	$1, %edi
	movl	(%rbx), %edx
	xorl	%eax, %eax
	addq	$12, %rbx
	call	__printf_chk@PLT
	cmpq	%rbx, %r12
	jne	.L61
	xorl	%eax, %eax
	jmp	.L40
.L132:
	movdqu	148(%rsp), %xmm0
	movl	$1, %edx
	xorl	%ecx, %ecx
	movl	$1, %r8d
	movdqu	164(%rsp), %xmm2
	pshufd	$27, %xmm0, %xmm0
	pshufd	$27, %xmm2, %xmm1
	movups	%xmm0, 164(%rsp)
	movups	%xmm1, 148(%rsp)
	.p2align 4,,10
	.p2align 3
.L62:
	movq	32(%rsp), %rax
	leaq	0(,%r8,4), %rsi
	leaq	(%rax,%rcx,4), %rdi
	movl	(%rdi), %ecx
	cmpl	%ecx, 144(%rsp,%r8,4)
	jg	.L67
	leal	1(%rdx), %eax
	cmpl	%ecx, 148(%rsp,%rsi)
	jg	.L58
	leal	2(%rdx), %eax
	cmpl	$7, %edx
	je	.L58
	cmpl	%ecx, 152(%rsp,%rsi)
	jg	.L58
	leal	3(%rdx), %eax
	cmpl	$6, %edx
	je	.L58
	cmpl	156(%rsp,%rsi), %ecx
	jl	.L58
	leal	4(%rdx), %eax
	cmpl	$5, %edx
	je	.L58
	cmpl	160(%rsp,%rsi), %ecx
	jl	.L58
	leal	5(%rdx), %eax
	cmpl	$4, %edx
	je	.L58
	cmpl	164(%rsp,%rsi), %ecx
	jl	.L58
	leal	6(%rdx), %eax
	cmpl	$3, %edx
	je	.L58
	cmpl	168(%rsp,%rsi), %ecx
	jl	.L58
	cmpl	$2, %edx
	je	.L76
	xorl	%eax, %eax
	cmpl	%ecx, 176(%rsp)
	setle	%al
	addl	$8, %eax
.L58:
	movq	32(%rsp), %rbx
	cltq
	leaq	(%rbx,%rax,4), %rax
	movl	(%rax), %edx
	movl	%ecx, (%rax)
	movl	%edx, (%rdi)
	jmp	.L45
.L131:
	movl	148(%rsp), %ebx
	movl	%edi, 80(%rsp)
	movl	%ecx, 88(%rsp)
	movl	%ebx, 68(%rsp)
	movl	152(%rsp), %ebx
	movb	%dl, 59(%rsp)
	movl	%ebx, 92(%rsp)
	movl	156(%rsp), %ebx
	movl	%eax, 44(%rsp)
	movl	%ebx, 64(%rsp)
	movl	160(%rsp), %ebx
	movl	%ebx, 84(%rsp)
	movl	164(%rsp), %ebx
	movl	%ebx, 60(%rsp)
	movl	168(%rsp), %ebx
	movl	%ebx, 76(%rsp)
	movl	40(%rsp), %ebx
	movl	%ebx, 72(%rsp)
	jmp	.L51
.L52:
	movl	172(%rsp), %ecx
	leaq	172(%rsp), %rdi
	cmpl	176(%rsp), %ecx
	jl	.L133
.L76:
	movl	$9, %eax
	jmp	.L58
.L70:
	movl	$6, %ecx
.L53:
	movq	32(%rsp), %rax
	leal	1(%rcx), %edx
	movslq	%edx, %r8
	leaq	(%rax,%r8,4), %rax
	movl	(%rax), %esi
	movl	%edi, (%rax)
	movl	%esi, 176(%rsp)
	jmp	.L62
.L133:
	movl	$8, %edx
.L67:
	movl	%edx, %eax
	jmp	.L58
.L74:
	movl	$2, %ecx
.L54:
	movq	172(%rsp), %xmm1
	movq	32(%rsp), %rax
	leal	1(%rcx), %edx
	movslq	%edx, %r8
	leaq	(%rax,%r8,4), %rax
	pshufd	$225, %xmm1, %xmm1
	movq	(%rax), %xmm0
	movq	%xmm1, (%rax)
	movl	$6, %eax
	subl	%ecx, %eax
	pshufd	$225, %xmm0, %xmm0
	shrl	%eax
	movq	%xmm0, 172(%rsp)
	cmpl	$1, %eax
	je	.L62
	movq	32(%rsp), %rbx
	leal	3(%rcx), %eax
	movl	168(%rsp), %edi
	cltq
	leaq	(%rbx,%rax,4), %rax
	movl	(%rax), %esi
	movl	%edi, (%rax)
	movl	%esi, 168(%rsp)
	jmp	.L62
.L73:
	movl	$3, %ecx
	jmp	.L54
.L72:
	movl	$4, %ecx
	jmp	.L54
.L71:
	movl	$5, %ecx
	jmp	.L53
.L75:
	movl	$1, %ecx
	jmp	.L54
.L129:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE40:
	.size	main, .-main
	.globl	cost
	.bss
	.align 32
	.type	cost, @object
	.size	cost, 400
cost:
	.zero	400
	.globl	count
	.align 32
	.type	count, @object
	.size	count, 400
count:
	.zero	400
	.globl	S
	.align 32
	.type	S, @object
	.size	S, 114514
S:
	.zero	114514
	.globl	N
	.align 4
	.type	N, @object
	.size	N, 4
N:
	.zero	4
	.section	.rodata.cst16,"aM",@progbits,16
	.align 16
.LC0:
	.long	1
	.long	2
	.long	3
	.long	4
	.align 16
.LC1:
	.long	5
	.long	6
	.long	7
	.long	8
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:

#include <stdio.h>
#include <stdlib.h>

/* {1,2,3} -> ... -> {3,2,1} */
int next_permutation(int arr[],int n) {
	int target;
	int i;
	int temp;
	for (i = n - 2; i >= 0; i--) {
		if (arr[i] < arr[i + 1]) break;
	}
	if (i < 0) return 0;
	target = i;

	for (i = 0; target + i + 1 < n - i - 1; i++) {
		temp = arr[target + 1 + i];
		arr[target + 1 + i] = arr[n - 1 - i];
		arr[n - i - 1] = temp;
	}

	for (i = target + 1; i < n; i++) {
		if (arr[i] > arr[target]) break;
	}
	temp = arr[i];
	arr[i] = arr[target];
	arr[target] = temp;
	return 1;
}

int N;
char S[114514];

int count[10][10];
int cost[10][10];

int main(void) {
	int i, j;
	int bestScore = -1;
	int bestHaiti[9] = {0};
	int haiti[9] = {1, 2, 3, 4, 5, 6, 7, 8, 9};
	if (scanf("%d", &N) != 1) return 1;
	if (scanf("%114513s", S) != 1) return 1;
	for (i = 1; i < N; i++) {
		count[S[i - 1] - '0'][S[i] - '0']++;
	}
	do {
		int score;
		for (i = 0; i < 9; i++) {
			int x1 = i % 3;
			int y1 = i / 3;
			for (j = i + 1; j < 9; j++) {
				int x2 = j % 3;
				int y2 = j / 3;
				cost[haiti[i]][haiti[j]] = cost[haiti[j]][haiti[i]] = abs(x1 - x2) + abs(y1 - y2);
			}
			cost[haiti[i]][haiti[i]] = 0;
		}
		score = 0;
		for (i = 1; i <= 9; i++) {
			for (j = 1; j <= 9; j++) {
				score += count[i][j] * cost[i][j];
			}
		}
		if (bestScore < 0 || score < bestScore) {
			bestScore = score;
			for (i = 0; i < 9; i++) bestHaiti[i] = haiti[i];
		}
	} while (next_permutation(haiti, 9));
	for (i = 0; i < 3; i++) {
		printf("%d%d%d\n", bestHaiti[i * 3], bestHaiti[i * 3 + 1], bestHaiti[i * 3 + 2]);
	}
	return 0;
}


10
1598114589
 11
18396312558
 10
2555486547
 10
2722382398
 10
2713182985
 10
4333783596
 11
24764186449
 10
1859787539
 10
1888971773
 10
6843843631

142
853
967
 124
857
369
 123
659
847
 139
428
576
 317
482
659
 124
783
695
 318
246
597
 124
853
796
 173
892
456
 125
347
689

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>

/* {1,2,3} -> ... -> {3,2,1} */
int next_permutation(int arr[],int n) {
	int target;
	int i;
	int temp;
	for (i = n - 2; i >= 0; i--) {
		if (arr[i] < arr[i + 1]) break;
	}
	if (i < 0) return 0;
	target = i;

	for (i = 0; target + i + 1 < n - i - 1; i++) {
		temp = arr[target + 1 + i];
		arr[target + 1 + i] = arr[n - 1 - i];
		arr[n - i - 1] = temp;
	}

	for (i = target + 1; i < n; i++) {
		if (arr[i] > arr[target]) break;
	}
	temp = arr[i];
	arr[i] = arr[target];
	arr[target] = temp;
	return 1;
}

int N;
char S[114514];

int count[10][10];
int cost[10][10];

int main(void) {
	int i, j;
	int bestScore = -1;
	int bestHaiti[9] = {0};
	int haiti[9] = {1, 2, 3, 4, 5, 6, 7, 8, 9};
	if (scanf("%d", &N) != 1) return 1;
	if (scanf("%114513s", S) != 1) return 1;
	for (i = 1; i < N; i++) {
		count[S[i - 1] - '0'][S[i] - '0']++;
	}
	do {
		int score;
		for (i = 0; i < 9; i++) {
			int x1 = i % 3;
			int y1 = i / 3;
			for (j = i + 1; j < 9; j++) {
				int x2 = j % 3;
				int y2 = j / 3;
				cost[haiti[i]][haiti[j]] = cost[haiti[j]][haiti[i]] = abs(x1 - x2) + abs(y1 - y2);
			}
			cost[haiti[i]][haiti[i]] = 0;
		}
		score = 0;
		for (i = 1; i <= 9; i++) {
			for (j = 1; j <= 9; j++) {
				score += count[i][j] * cost[i][j];
			}
		}
		if (bestScore < 0 || score < bestScore) {
			bestScore = score;
			for (i = 0; i < 9; i++) bestHaiti[i] = haiti[i];
		}
	} while (next_permutation(haiti, 9));
	for (i = 0; i < 3; i++) {
		printf("%d%d%d\n", bestHaiti[i * 3], bestHaiti[i * 3 + 1], bestHaiti[i * 3 + 2]);
	}
	return 0;
}

```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	next_permutation
	.type	next_permutation, @function
next_permutation:
.LFB6:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movq	%rdi, -24(%rbp)
	movl	%esi, -28(%rbp)
	movl	-28(%rbp), %eax
	subl	$2, %eax
	movl	%eax, -12(%rbp)
	jmp	.L2
.L5:
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %edx
	movl	-12(%rbp), %eax
	cltq
	addq	$1, %rax
	leaq	0(,%rax,4), %rcx
	movq	-24(%rbp), %rax
	addq	%rcx, %rax
	movl	(%rax), %eax
	cmpl	%eax, %edx
	jl	.L14
	subl	$1, -12(%rbp)
.L2:
	cmpl	$0, -12(%rbp)
	jns	.L5
	jmp	.L4
.L14:
	nop
.L4:
	cmpl	$0, -12(%rbp)
	jns	.L6
	movl	$0, %eax
	jmp	.L7
.L6:
	movl	-12(%rbp), %eax
	movl	%eax, -8(%rbp)
	movl	$0, -12(%rbp)
	jmp	.L8
.L9:
	movl	-8(%rbp), %eax
	leal	1(%rax), %edx
	movl	-12(%rbp), %eax
	addl	%edx, %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	movl	%eax, -4(%rbp)
	movl	-28(%rbp), %eax
	subl	$1, %eax
	subl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	-8(%rbp), %edx
	leal	1(%rdx), %ecx
	movl	-12(%rbp), %edx
	addl	%ecx, %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	movq	-24(%rbp), %rdx
	addq	%rcx, %rdx
	movl	(%rax), %eax
	movl	%eax, (%rdx)
	movl	-28(%rbp), %eax
	subl	-12(%rbp), %eax
	cltq
	salq	$2, %rax
	leaq	-4(%rax), %rdx
	movq	-24(%rbp), %rax
	addq	%rax, %rdx
	movl	-4(%rbp), %eax
	movl	%eax, (%rdx)
	addl	$1, -12(%rbp)
.L8:
	movl	-8(%rbp), %edx
	movl	-12(%rbp), %eax
	addl	%edx, %eax
	leal	1(%rax), %edx
	movl	-28(%rbp), %eax
	subl	-12(%rbp), %eax
	subl	$1, %eax
	cmpl	%eax, %edx
	jl	.L9
	movl	-8(%rbp), %eax
	addl	$1, %eax
	movl	%eax, -12(%rbp)
	jmp	.L10
.L13:
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %edx
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	movq	-24(%rbp), %rax
	addq	%rcx, %rax
	movl	(%rax), %eax
	cmpl	%eax, %edx
	jg	.L15
	addl	$1, -12(%rbp)
.L10:
	movl	-12(%rbp), %eax
	cmpl	-28(%rbp), %eax
	jl	.L13
	jmp	.L12
.L15:
	nop
.L12:
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	movl	%eax, -4(%rbp)
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	-12(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	movq	-24(%rbp), %rdx
	addq	%rcx, %rdx
	movl	(%rax), %eax
	movl	%eax, (%rdx)
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rax, %rdx
	movl	-4(%rbp), %eax
	movl	%eax, (%rdx)
	movl	$1, %eax
.L7:
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	next_permutation, .-next_permutation
	.globl	N
	.bss
	.align 4
	.type	N, @object
	.size	N, 4
N:
	.zero	4
	.globl	S
	.align 32
	.type	S, @object
	.size	S, 114514
S:
	.zero	114514
	.globl	count
	.align 32
	.type	count, @object
	.size	count, 400
count:
	.zero	400
	.globl	cost
	.align 32
	.type	cost, @object
	.size	cost, 400
cost:
	.zero	400
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%114513s"
.LC2:
	.string	"%d%d%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB7:
	.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	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	$-1, -120(%rbp)
	movq	$0, -96(%rbp)
	movq	$0, -88(%rbp)
	movq	$0, -80(%rbp)
	movq	$0, -72(%rbp)
	movl	$0, -64(%rbp)
	movl	$1, -48(%rbp)
	movl	$2, -44(%rbp)
	movl	$3, -40(%rbp)
	movl	$4, -36(%rbp)
	movl	$5, -32(%rbp)
	movl	$6, -28(%rbp)
	movl	$7, -24(%rbp)
	movl	$8, -20(%rbp)
	movl	$9, -16(%rbp)
	leaq	N(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	cmpl	$1, %eax
	je	.L17
	movl	$1, %eax
	jmp	.L37
.L17:
	leaq	S(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	cmpl	$1, %eax
	je	.L19
	movl	$1, %eax
	jmp	.L37
.L19:
	movl	$1, -128(%rbp)
	jmp	.L20
.L21:
	movl	-128(%rbp), %eax
	subl	$1, %eax
	cltq
	leaq	S(%rip), %rdx
	movzbl	(%rax,%rdx), %eax
	movsbl	%al, %eax
	leal	-48(%rax), %edx
	movl	-128(%rbp), %eax
	cltq
	leaq	S(%rip), %rcx
	movzbl	(%rax,%rcx), %eax
	movsbl	%al, %eax
	leal	-48(%rax), %ecx
	movslq	%ecx, %rdi
	movslq	%edx, %rsi
	movq	%rsi, %rax
	salq	$2, %rax
	addq	%rsi, %rax
	addq	%rax, %rax
	addq	%rdi, %rax
	leaq	0(,%rax,4), %rsi
	leaq	count(%rip), %rax
	movl	(%rsi,%rax), %eax
	leal	1(%rax), %esi
	movslq	%ecx, %rcx
	movslq	%edx, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rax, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	count(%rip), %rax
	movl	%esi, (%rdx,%rax)
	addl	$1, -128(%rbp)
.L20:
	movl	N(%rip), %eax
	cmpl	%eax, -128(%rbp)
	jl	.L21
.L34:
	movl	$0, -128(%rbp)
	jmp	.L22
.L25:
	movl	-128(%rbp), %eax
	movslq	%eax, %rdx
	imulq	$1431655766, %rdx, %rdx
	shrq	$32, %rdx
	movl	%eax, %esi
	sarl	$31, %esi
	movl	%edx, %ecx
	subl	%esi, %ecx
	movl	%ecx, %edx
	addl	%edx, %edx
	addl	%ecx, %edx
	subl	%edx, %eax
	movl	%eax, -112(%rbp)
	movl	-128(%rbp), %eax
	movslq	%eax, %rdx
	imulq	$1431655766, %rdx, %rdx
	shrq	$32, %rdx
	sarl	$31, %eax
	movl	%eax, %ecx
	movl	%edx, %eax
	subl	%ecx, %eax
	movl	%eax, -108(%rbp)
	movl	-128(%rbp), %eax
	addl	$1, %eax
	movl	%eax, -124(%rbp)
	jmp	.L23
.L24:
	movl	-124(%rbp), %eax
	movslq	%eax, %rdx
	imulq	$1431655766, %rdx, %rdx
	shrq	$32, %rdx
	movl	%eax, %esi
	sarl	$31, %esi
	movl	%edx, %ecx
	subl	%esi, %ecx
	movl	%ecx, %edx
	addl	%edx, %edx
	addl	%ecx, %edx
	subl	%edx, %eax
	movl	%eax, -104(%rbp)
	movl	-124(%rbp), %eax
	movslq	%eax, %rdx
	imulq	$1431655766, %rdx, %rdx
	shrq	$32, %rdx
	sarl	$31, %eax
	movl	%eax, %ecx
	movl	%edx, %eax
	subl	%ecx, %eax
	movl	%eax, -100(%rbp)
	movl	-112(%rbp), %eax
	subl	-104(%rbp), %eax
	movl	%eax, %edx
	negl	%edx
	cmovns	%edx, %eax
	movl	%eax, %edi
	movl	-108(%rbp), %eax
	subl	-100(%rbp), %eax
	movl	%eax, %edx
	negl	%edx
	cmovns	%edx, %eax
	movl	%eax, %esi
	movl	-124(%rbp), %eax
	cltq
	movl	-48(%rbp,%rax,4), %edx
	movl	-128(%rbp), %eax
	cltq
	movl	-48(%rbp,%rax,4), %ecx
	addl	%esi, %edi
	movslq	%ecx, %r8
	movslq	%edx, %rsi
	movq	%rsi, %rax
	salq	$2, %rax
	addq	%rsi, %rax
	addq	%rax, %rax
	addq	%r8, %rax
	leaq	0(,%rax,4), %rsi
	leaq	cost(%rip), %rax
	movl	%edi, (%rsi,%rax)
	movl	-128(%rbp), %eax
	cltq
	movl	-48(%rbp,%rax,4), %esi
	movl	-124(%rbp), %eax
	cltq
	movl	-48(%rbp,%rax,4), %edi
	movslq	%ecx, %rcx
	movslq	%edx, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rax, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	cost(%rip), %rax
	movl	(%rdx,%rax), %edx
	movslq	%edi, %rdi
	movslq	%esi, %rcx
	movq	%rcx, %rax
	salq	$2, %rax
	addq	%rcx, %rax
	addq	%rax, %rax
	addq	%rdi, %rax
	leaq	0(,%rax,4), %rcx
	leaq	cost(%rip), %rax
	movl	%edx, (%rcx,%rax)
	addl	$1, -124(%rbp)
.L23:
	cmpl	$8, -124(%rbp)
	jle	.L24
	movl	-128(%rbp), %eax
	cltq
	movl	-48(%rbp,%rax,4), %edx
	movl	-128(%rbp), %eax
	cltq
	movl	-48(%rbp,%rax,4), %eax
	movslq	%eax, %rcx
	movslq	%edx, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rax, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	cost(%rip), %rax
	movl	$0, (%rdx,%rax)
	addl	$1, -128(%rbp)
.L22:
	cmpl	$8, -128(%rbp)
	jle	.L25
	movl	$0, -116(%rbp)
	movl	$1, -128(%rbp)
	jmp	.L26
.L29:
	movl	$1, -124(%rbp)
	jmp	.L27
.L28:
	movl	-124(%rbp), %eax
	movslq	%eax, %rcx
	movl	-128(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rax, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	count(%rip), %rax
	movl	(%rdx,%rax), %ecx
	movl	-124(%rbp), %eax
	movslq	%eax, %rsi
	movl	-128(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rax, %rax
	addq	%rsi, %rax
	leaq	0(,%rax,4), %rdx
	leaq	cost(%rip), %rax
	movl	(%rdx,%rax), %eax
	imull	%ecx, %eax
	addl	%eax, -116(%rbp)
	addl	$1, -124(%rbp)
.L27:
	cmpl	$9, -124(%rbp)
	jle	.L28
	addl	$1, -128(%rbp)
.L26:
	cmpl	$9, -128(%rbp)
	jle	.L29
	cmpl	$0, -120(%rbp)
	js	.L30
	movl	-116(%rbp), %eax
	cmpl	-120(%rbp), %eax
	jge	.L31
.L30:
	movl	-116(%rbp), %eax
	movl	%eax, -120(%rbp)
	movl	$0, -128(%rbp)
	jmp	.L32
.L33:
	movl	-128(%rbp), %eax
	cltq
	movl	-48(%rbp,%rax,4), %edx
	movl	-128(%rbp), %eax
	cltq
	movl	%edx, -96(%rbp,%rax,4)
	addl	$1, -128(%rbp)
.L32:
	cmpl	$8, -128(%rbp)
	jle	.L33
.L31:
	leaq	-48(%rbp), %rax
	movl	$9, %esi
	movq	%rax, %rdi
	call	next_permutation
	testl	%eax, %eax
	jne	.L34
	movl	$0, -128(%rbp)
	jmp	.L35
.L36:
	movl	-128(%rbp), %edx
	movl	%edx, %eax
	addl	%eax, %eax
	addl	%edx, %eax
	addl	$2, %eax
	cltq
	movl	-96(%rbp,%rax,4), %ecx
	movl	-128(%rbp), %edx
	movl	%edx, %eax
	addl	%eax, %eax
	addl	%edx, %eax
	addl	$1, %eax
	cltq
	movl	-96(%rbp,%rax,4), %edx
	movl	-128(%rbp), %esi
	movl	%esi, %eax
	addl	%eax, %eax
	addl	%esi, %eax
	cltq
	movl	-96(%rbp,%rax,4), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	addl	$1, -128(%rbp)
.L35:
	cmpl	$2, -128(%rbp)
	jle	.L36
	movl	$0, %eax
.L37:
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L38
	call	__stack_chk_fail@PLT
.L38:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.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	next_permutation
	.type	next_permutation, @function
next_permutation:
.LFB6:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movq	%rdi, -24(%rbp)
	movl	%esi, -28(%rbp)
	movl	-28(%rbp), %eax
	subl	$2, %eax
	movl	%eax, -12(%rbp)
	jmp	.L2
.L5:
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %edx
	movl	-12(%rbp), %eax
	cltq
	addq	$1, %rax
	leaq	0(,%rax,4), %rcx
	movq	-24(%rbp), %rax
	addq	%rcx, %rax
	movl	(%rax), %eax
	cmpl	%eax, %edx
	jl	.L14
	subl	$1, -12(%rbp)
.L2:
	cmpl	$0, -12(%rbp)
	jns	.L5
	jmp	.L4
.L14:
	nop
.L4:
	cmpl	$0, -12(%rbp)
	jns	.L6
	movl	$0, %eax
	jmp	.L7
.L6:
	movl	-12(%rbp), %eax
	movl	%eax, -8(%rbp)
	movl	$0, -12(%rbp)
	jmp	.L8
.L9:
	movl	-8(%rbp), %eax
	leal	1(%rax), %edx
	movl	-12(%rbp), %eax
	addl	%edx, %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	movl	%eax, -4(%rbp)
	movl	-28(%rbp), %eax
	subl	$1, %eax
	subl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	-8(%rbp), %edx
	leal	1(%rdx), %ecx
	movl	-12(%rbp), %edx
	addl	%ecx, %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	movq	-24(%rbp), %rdx
	addq	%rcx, %rdx
	movl	(%rax), %eax
	movl	%eax, (%rdx)
	movl	-28(%rbp), %eax
	subl	-12(%rbp), %eax
	cltq
	salq	$2, %rax
	leaq	-4(%rax), %rdx
	movq	-24(%rbp), %rax
	addq	%rax, %rdx
	movl	-4(%rbp), %eax
	movl	%eax, (%rdx)
	addl	$1, -12(%rbp)
.L8:
	movl	-8(%rbp), %edx
	movl	-12(%rbp), %eax
	addl	%edx, %eax
	leal	1(%rax), %edx
	movl	-28(%rbp), %eax
	subl	-12(%rbp), %eax
	subl	$1, %eax
	cmpl	%eax, %edx
	jl	.L9
	movl	-8(%rbp), %eax
	addl	$1, %eax
	movl	%eax, -12(%rbp)
	jmp	.L10
.L13:
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %edx
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	movq	-24(%rbp), %rax
	addq	%rcx, %rax
	movl	(%rax), %eax
	cmpl	%eax, %edx
	jg	.L15
	addl	$1, -12(%rbp)
.L10:
	movl	-12(%rbp), %eax
	cmpl	-28(%rbp), %eax
	jl	.L13
	jmp	.L12
.L15:
	nop
.L12:
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	movl	%eax, -4(%rbp)
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movl	-12(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	movq	-24(%rbp), %rdx
	addq	%rcx, %rdx
	movl	(%rax), %eax
	movl	%eax, (%rdx)
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-24(%rbp), %rax
	addq	%rax, %rdx
	movl	-4(%rbp), %eax
	movl	%eax, (%rdx)
	movl	$1, %eax
.L7:
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	next_permutation, .-next_permutation
	.globl	N
	.bss
	.align 4
	.type	N, @object
	.size	N, 4
N:
	.zero	4
	.globl	S
	.align 32
	.type	S, @object
	.size	S, 114514
S:
	.zero	114514
	.globl	count
	.align 32
	.type	count, @object
	.size	count, 400
count:
	.zero	400
	.globl	cost
	.align 32
	.type	cost, @object
	.size	cost, 400
cost:
	.zero	400
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%114513s"
.LC2:
	.string	"%d%d%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB7:
	.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	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	$-1, -120(%rbp)
	movq	$0, -96(%rbp)
	movq	$0, -88(%rbp)
	movq	$0, -80(%rbp)
	movq	$0, -72(%rbp)
	movl	$0, -64(%rbp)
	movl	$1, -48(%rbp)
	movl	$2, -44(%rbp)
	movl	$3, -40(%rbp)
	movl	$4, -36(%rbp)
	movl	$5, -32(%rbp)
	movl	$6, -28(%rbp)
	movl	$7, -24(%rbp)
	movl	$8, -20(%rbp)
	movl	$9, -16(%rbp)
	leaq	N(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	cmpl	$1, %eax
	je	.L17
	movl	$1, %eax
	jmp	.L37
.L17:
	leaq	S(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	cmpl	$1, %eax
	je	.L19
	movl	$1, %eax
	jmp	.L37
.L19:
	movl	$1, -128(%rbp)
	jmp	.L20
.L21:
	movl	-128(%rbp), %eax
	subl	$1, %eax
	cltq
	leaq	S(%rip), %rdx
	movzbl	(%rax,%rdx), %eax
	movsbl	%al, %eax
	leal	-48(%rax), %edx
	movl	-128(%rbp), %eax
	cltq
	leaq	S(%rip), %rcx
	movzbl	(%rax,%rcx), %eax
	movsbl	%al, %eax
	leal	-48(%rax), %ecx
	movslq	%ecx, %rdi
	movslq	%edx, %rsi
	movq	%rsi, %rax
	salq	$2, %rax
	addq	%rsi, %rax
	addq	%rax, %rax
	addq	%rdi, %rax
	leaq	0(,%rax,4), %rsi
	leaq	count(%rip), %rax
	movl	(%rsi,%rax), %eax
	leal	1(%rax), %esi
	movslq	%ecx, %rcx
	movslq	%edx, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rax, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	count(%rip), %rax
	movl	%esi, (%rdx,%rax)
	addl	$1, -128(%rbp)
.L20:
	movl	N(%rip), %eax
	cmpl	%eax, -128(%rbp)
	jl	.L21
.L34:
	movl	$0, -128(%rbp)
	jmp	.L22
.L25:
	movl	-128(%rbp), %eax
	movslq	%eax, %rdx
	imulq	$1431655766, %rdx, %rdx
	shrq	$32, %rdx
	movl	%eax, %esi
	sarl	$31, %esi
	movl	%edx, %ecx
	subl	%esi, %ecx
	movl	%ecx, %edx
	addl	%edx, %edx
	addl	%ecx, %edx
	subl	%edx, %eax
	movl	%eax, -112(%rbp)
	movl	-128(%rbp), %eax
	movslq	%eax, %rdx
	imulq	$1431655766, %rdx, %rdx
	shrq	$32, %rdx
	sarl	$31, %eax
	movl	%eax, %ecx
	movl	%edx, %eax
	subl	%ecx, %eax
	movl	%eax, -108(%rbp)
	movl	-128(%rbp), %eax
	addl	$1, %eax
	movl	%eax, -124(%rbp)
	jmp	.L23
.L24:
	movl	-124(%rbp), %eax
	movslq	%eax, %rdx
	imulq	$1431655766, %rdx, %rdx
	shrq	$32, %rdx
	movl	%eax, %esi
	sarl	$31, %esi
	movl	%edx, %ecx
	subl	%esi, %ecx
	movl	%ecx, %edx
	addl	%edx, %edx
	addl	%ecx, %edx
	subl	%edx, %eax
	movl	%eax, -104(%rbp)
	movl	-124(%rbp), %eax
	movslq	%eax, %rdx
	imulq	$1431655766, %rdx, %rdx
	shrq	$32, %rdx
	sarl	$31, %eax
	movl	%eax, %ecx
	movl	%edx, %eax
	subl	%ecx, %eax
	movl	%eax, -100(%rbp)
	movl	-112(%rbp), %eax
	subl	-104(%rbp), %eax
	movl	%eax, %edx
	negl	%edx
	cmovns	%edx, %eax
	movl	%eax, %edi
	movl	-108(%rbp), %eax
	subl	-100(%rbp), %eax
	movl	%eax, %edx
	negl	%edx
	cmovns	%edx, %eax
	movl	%eax, %esi
	movl	-124(%rbp), %eax
	cltq
	movl	-48(%rbp,%rax,4), %edx
	movl	-128(%rbp), %eax
	cltq
	movl	-48(%rbp,%rax,4), %ecx
	addl	%esi, %edi
	movslq	%ecx, %r8
	movslq	%edx, %rsi
	movq	%rsi, %rax
	salq	$2, %rax
	addq	%rsi, %rax
	addq	%rax, %rax
	addq	%r8, %rax
	leaq	0(,%rax,4), %rsi
	leaq	cost(%rip), %rax
	movl	%edi, (%rsi,%rax)
	movl	-128(%rbp), %eax
	cltq
	movl	-48(%rbp,%rax,4), %esi
	movl	-124(%rbp), %eax
	cltq
	movl	-48(%rbp,%rax,4), %edi
	movslq	%ecx, %rcx
	movslq	%edx, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rax, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	cost(%rip), %rax
	movl	(%rdx,%rax), %edx
	movslq	%edi, %rdi
	movslq	%esi, %rcx
	movq	%rcx, %rax
	salq	$2, %rax
	addq	%rcx, %rax
	addq	%rax, %rax
	addq	%rdi, %rax
	leaq	0(,%rax,4), %rcx
	leaq	cost(%rip), %rax
	movl	%edx, (%rcx,%rax)
	addl	$1, -124(%rbp)
.L23:
	cmpl	$8, -124(%rbp)
	jle	.L24
	movl	-128(%rbp), %eax
	cltq
	movl	-48(%rbp,%rax,4), %edx
	movl	-128(%rbp), %eax
	cltq
	movl	-48(%rbp,%rax,4), %eax
	movslq	%eax, %rcx
	movslq	%edx, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rax, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	cost(%rip), %rax
	movl	$0, (%rdx,%rax)
	addl	$1, -128(%rbp)
.L22:
	cmpl	$8, -128(%rbp)
	jle	.L25
	movl	$0, -116(%rbp)
	movl	$1, -128(%rbp)
	jmp	.L26
.L29:
	movl	$1, -124(%rbp)
	jmp	.L27
.L28:
	movl	-124(%rbp), %eax
	movslq	%eax, %rcx
	movl	-128(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rax, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	count(%rip), %rax
	movl	(%rdx,%rax), %ecx
	movl	-124(%rbp), %eax
	movslq	%eax, %rsi
	movl	-128(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rax, %rax
	addq	%rsi, %rax
	leaq	0(,%rax,4), %rdx
	leaq	cost(%rip), %rax
	movl	(%rdx,%rax), %eax
	imull	%ecx, %eax
	addl	%eax, -116(%rbp)
	addl	$1, -124(%rbp)
.L27:
	cmpl	$9, -124(%rbp)
	jle	.L28
	addl	$1, -128(%rbp)
.L26:
	cmpl	$9, -128(%rbp)
	jle	.L29
	cmpl	$0, -120(%rbp)
	js	.L30
	movl	-116(%rbp), %eax
	cmpl	-120(%rbp), %eax
	jge	.L31
.L30:
	movl	-116(%rbp), %eax
	movl	%eax, -120(%rbp)
	movl	$0, -128(%rbp)
	jmp	.L32
.L33:
	movl	-128(%rbp), %eax
	cltq
	movl	-48(%rbp,%rax,4), %edx
	movl	-128(%rbp), %eax
	cltq
	movl	%edx, -96(%rbp,%rax,4)
	addl	$1, -128(%rbp)
.L32:
	cmpl	$8, -128(%rbp)
	jle	.L33
.L31:
	leaq	-48(%rbp), %rax
	movl	$9, %esi
	movq	%rax, %rdi
	call	next_permutation
	testl	%eax, %eax
	jne	.L34
	movl	$0, -128(%rbp)
	jmp	.L35
.L36:
	movl	-128(%rbp), %edx
	movl	%edx, %eax
	addl	%eax, %eax
	addl	%edx, %eax
	addl	$2, %eax
	cltq
	movl	-96(%rbp,%rax,4), %ecx
	movl	-128(%rbp), %edx
	movl	%edx, %eax
	addl	%eax, %eax
	addl	%edx, %eax
	addl	$1, %eax
	cltq
	movl	-96(%rbp,%rax,4), %edx
	movl	-128(%rbp), %esi
	movl	%esi, %eax
	addl	%eax, %eax
	addl	%esi, %eax
	cltq
	movl	-96(%rbp,%rax,4), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	addl	$1, -128(%rbp)
.L35:
	cmpl	$2, -128(%rbp)
	jle	.L36
	movl	$0, %eax
.L37:
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L38
	call	__stack_chk_fail@PLT
.L38:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.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:
