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

```c
// AOJ 2040 Sort the Panels
// 2018.3.13 bal4u

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

#define QMAX 300000
typedef struct { int s; char p; char t; } QUE;
QUE que[QMAX]; int qsize, qmax;

#define PARENT(i) ((i)>>1)
#define LEFT(i)   ((i)<<1)
#define RIGHT(i)  (((i)<<1)+1)

void min_heapify(int i)
{
	int l, r, min;
	QUE qt;

	l = LEFT(i), r = RIGHT(i);
	if (l < qsize && que[l].t < que[i].t) min = l; else min = i;
	if (r < qsize && que[r].t < que[min].t) min = r;
	if (min != i) {
		qt = que[i], que[i] = que[min], que[min] = qt;
		min_heapify(min);
	}
}

void deq()
{
	que[0] = que[--qsize];
	min_heapify(0);
}

void enq(int s, int t, char p)
{
	int i, min;
	QUE qt;

	i = qsize++;
	que[i].s = s, que[i].t = t, que[i].p = p;
	while (i > 0 && que[min = PARENT(i)].t > que[i].t) {
		qt = que[i], que[i] = que[min], que[min] = qt;
		i = min;
	}
}

#define ABS(a)  ((a)>=0?(a):-(a))
char dist[1<<16][16];

int dijkstra(int n, int nb, int start, int goal)
{
	int i, j, k, m, s, t, p, ns, nt, nw;
	int pi, ij;

	memset(dist, 75, sizeof(dist));
	qsize = 0;
	t = -1, nw = n - nb;
	for (p = 0; p < n; p++) dist[start][p] = 0, enq(start, 0, p);
	while (qsize) {
		s = que[0].s, t = que[0].t, p = que[0].p, deq();
		if (s == goal) break;

		if (dist[s][p] < t) continue;

		for (k = i = 0; k < nb; i++) if (s & (1<<i)) { k++, pi = ABS(p-i);
			for (m = j = 0; m < nw; j++) if (!(s & (1<<j))) { m++;
				ij = ABS(j-i);
				ns = s ^ (1<<i) ^ (1<<j);
				nt = t + pi+ij;
				if (dist[ns][j] > nt) dist[ns][j] = nt, enq(ns, nt, j);
				nt = t + ABS(p-j)+ij;
				if (dist[ns][i] > nt) dist[ns][i] = nt, enq(ns, nt, i);
			}
		}
	}
	return t;
}

int calc(char *s) { int res=0; while (*s > ' ') res = (res<<1)|(*s++ == 'B'); return res; }

int main()
{
	int n, nb, start, goal;
	char buf[20], *p;

	while (fgets(buf, 10, stdin) && *buf != '0') {
		n = atoi(buf);
		fgets(p=buf, 20, stdin); nb = 0; while (*p > ' ') if (*p++ == 'B') nb++;
		start = calc(buf);
		fgets(buf, 20, stdin), goal = calc(buf);
		if (nb > n-nb) {
			nb = n-nb;
			start = ~start & ((1<<n)-1), goal = ~goal & ((1<<n)-1);
		}
		printf("%d\n", dijkstra(n, nb, start, goal));
	}
	return 0;
}
```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	que
	.bss
	.align 32
	.type	que, @object
	.size	que, 2400000
que:
	.zero	2400000
	.globl	qsize
	.align 4
	.type	qsize, @object
	.size	qsize, 4
qsize:
	.zero	4
	.globl	qmax
	.align 4
	.type	qmax, @object
	.size	qmax, 4
qmax:
	.zero	4
	.text
	.globl	min_heapify
	.type	min_heapify, @function
min_heapify:
.LFB6:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$48, %rsp
	movl	%edi, -36(%rbp)
	movl	-36(%rbp), %eax
	addl	%eax, %eax
	movl	%eax, -16(%rbp)
	movl	-36(%rbp), %eax
	addl	%eax, %eax
	addl	$1, %eax
	movl	%eax, -12(%rbp)
	movl	qsize(%rip), %eax
	cmpl	%eax, -16(%rbp)
	jge	.L2
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	5+que(%rip), %rax
	movzbl	(%rdx,%rax), %edx
	movl	-36(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rcx
	leaq	5+que(%rip), %rax
	movzbl	(%rcx,%rax), %eax
	cmpb	%al, %dl
	jge	.L2
	movl	-16(%rbp), %eax
	movl	%eax, -20(%rbp)
	jmp	.L3
.L2:
	movl	-36(%rbp), %eax
	movl	%eax, -20(%rbp)
.L3:
	movl	qsize(%rip), %eax
	cmpl	%eax, -12(%rbp)
	jge	.L4
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	5+que(%rip), %rax
	movzbl	(%rdx,%rax), %edx
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rcx
	leaq	5+que(%rip), %rax
	movzbl	(%rcx,%rax), %eax
	cmpb	%al, %dl
	jge	.L4
	movl	-12(%rbp), %eax
	movl	%eax, -20(%rbp)
.L4:
	movl	-20(%rbp), %eax
	cmpl	-36(%rbp), %eax
	je	.L6
	movl	-36(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	que(%rip), %rax
	movq	(%rdx,%rax), %rax
	movq	%rax, -8(%rbp)
	movl	-36(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rcx
	leaq	que(%rip), %rdx
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rsi
	leaq	que(%rip), %rax
	movq	(%rsi,%rax), %rax
	movq	%rax, (%rcx,%rdx)
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rcx
	leaq	que(%rip), %rdx
	movq	-8(%rbp), %rax
	movq	%rax, (%rcx,%rdx)
	movl	-20(%rbp), %eax
	movl	%eax, %edi
	call	min_heapify
.L6:
	nop
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	min_heapify, .-min_heapify
	.globl	deq
	.type	deq, @function
deq:
.LFB7:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	qsize(%rip), %eax
	subl	$1, %eax
	movl	%eax, qsize(%rip)
	movl	qsize(%rip), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	que(%rip), %rax
	movq	(%rdx,%rax), %rax
	movq	%rax, que(%rip)
	movl	$0, %edi
	call	min_heapify
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.size	deq, .-deq
	.globl	enq
	.type	enq, @function
enq:
.LFB8:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	%edi, -20(%rbp)
	movl	%esi, -24(%rbp)
	movl	%edx, %eax
	movb	%al, -28(%rbp)
	movl	qsize(%rip), %eax
	leal	1(%rax), %edx
	movl	%edx, qsize(%rip)
	movl	%eax, -16(%rbp)
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rcx
	leaq	que(%rip), %rdx
	movl	-20(%rbp), %eax
	movl	%eax, (%rcx,%rdx)
	movl	-24(%rbp), %eax
	movl	%eax, %ecx
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	5+que(%rip), %rax
	movb	%cl, (%rdx,%rax)
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rcx
	leaq	4+que(%rip), %rdx
	movzbl	-28(%rbp), %eax
	movb	%al, (%rcx,%rdx)
	jmp	.L9
.L11:
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	que(%rip), %rax
	movq	(%rdx,%rax), %rax
	movq	%rax, -8(%rbp)
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rcx
	leaq	que(%rip), %rdx
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rsi
	leaq	que(%rip), %rax
	movq	(%rsi,%rax), %rax
	movq	%rax, (%rcx,%rdx)
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rcx
	leaq	que(%rip), %rdx
	movq	-8(%rbp), %rax
	movq	%rax, (%rcx,%rdx)
	movl	-12(%rbp), %eax
	movl	%eax, -16(%rbp)
.L9:
	cmpl	$0, -16(%rbp)
	jle	.L12
	movl	-16(%rbp), %eax
	sarl	%eax
	movl	%eax, -12(%rbp)
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	5+que(%rip), %rax
	movzbl	(%rdx,%rax), %edx
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rcx
	leaq	5+que(%rip), %rax
	movzbl	(%rcx,%rax), %eax
	cmpb	%al, %dl
	jg	.L11
.L12:
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE8:
	.size	enq, .-enq
	.globl	dist
	.bss
	.align 32
	.type	dist, @object
	.size	dist, 1048576
dist:
	.zero	1048576
	.text
	.globl	dijkstra
	.type	dijkstra, @function
dijkstra:
.LFB9:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$64, %rsp
	movl	%edi, -52(%rbp)
	movl	%esi, -56(%rbp)
	movl	%edx, -60(%rbp)
	movl	%ecx, -64(%rbp)
	movl	$1048576, %edx
	movl	$75, %esi
	leaq	dist(%rip), %rax
	movq	%rax, %rdi
	call	memset@PLT
	movl	$0, qsize(%rip)
	movl	$-1, -32(%rbp)
	movl	-52(%rbp), %eax
	subl	-56(%rbp), %eax
	movl	%eax, -24(%rbp)
	movl	$0, -28(%rbp)
	jmp	.L14
.L15:
	movl	-28(%rbp), %eax
	movslq	%eax, %rdx
	movl	-60(%rbp), %eax
	cltq
	salq	$4, %rax
	addq	%rax, %rdx
	leaq	dist(%rip), %rax
	addq	%rdx, %rax
	movb	$0, (%rax)
	movl	-28(%rbp), %eax
	movsbl	%al, %edx
	movl	-60(%rbp), %eax
	movl	$0, %esi
	movl	%eax, %edi
	call	enq
	addl	$1, -28(%rbp)
.L14:
	movl	-28(%rbp), %eax
	cmpl	-52(%rbp), %eax
	jl	.L15
	jmp	.L16
.L27:
	movl	que(%rip), %eax
	movl	%eax, -20(%rbp)
	movzbl	5+que(%rip), %eax
	movsbl	%al, %eax
	movl	%eax, -32(%rbp)
	movzbl	4+que(%rip), %eax
	movsbl	%al, %eax
	movl	%eax, -28(%rbp)
	movl	$0, %eax
	call	deq
	movl	-20(%rbp), %eax
	cmpl	-64(%rbp), %eax
	je	.L29
	movl	-28(%rbp), %eax
	movslq	%eax, %rdx
	movl	-20(%rbp), %eax
	cltq
	salq	$4, %rax
	addq	%rax, %rdx
	leaq	dist(%rip), %rax
	addq	%rdx, %rax
	movzbl	(%rax), %eax
	movsbl	%al, %eax
	cmpl	%eax, -32(%rbp)
	jle	.L19
	jmp	.L16
.L19:
	movl	$0, -48(%rbp)
	movl	-48(%rbp), %eax
	movl	%eax, -40(%rbp)
	jmp	.L20
.L26:
	movl	-48(%rbp), %eax
	movl	-20(%rbp), %edx
	movl	%eax, %ecx
	sarl	%cl, %edx
	movl	%edx, %eax
	andl	$1, %eax
	testl	%eax, %eax
	je	.L21
	addl	$1, -40(%rbp)
	movl	-28(%rbp), %eax
	subl	-48(%rbp), %eax
	movl	%eax, %edx
	negl	%edx
	cmovns	%edx, %eax
	movl	%eax, -16(%rbp)
	movl	$0, -44(%rbp)
	movl	-44(%rbp), %eax
	movl	%eax, -36(%rbp)
	jmp	.L22
.L25:
	movl	-44(%rbp), %eax
	movl	-20(%rbp), %edx
	movl	%eax, %ecx
	sarl	%cl, %edx
	movl	%edx, %eax
	andl	$1, %eax
	testl	%eax, %eax
	jne	.L23
	addl	$1, -36(%rbp)
	movl	-44(%rbp), %eax
	subl	-48(%rbp), %eax
	movl	%eax, %edx
	negl	%edx
	cmovns	%edx, %eax
	movl	%eax, -12(%rbp)
	movl	-48(%rbp), %eax
	movl	$1, %edx
	movl	%eax, %ecx
	sall	%cl, %edx
	movl	%edx, %eax
	xorl	-20(%rbp), %eax
	movl	%eax, %edx
	movl	-44(%rbp), %eax
	movl	$1, %esi
	movl	%eax, %ecx
	sall	%cl, %esi
	movl	%esi, %eax
	xorl	%edx, %eax
	movl	%eax, -8(%rbp)
	movl	-32(%rbp), %edx
	movl	-16(%rbp), %eax
	addl	%eax, %edx
	movl	-12(%rbp), %eax
	addl	%edx, %eax
	movl	%eax, -4(%rbp)
	movl	-44(%rbp), %eax
	movslq	%eax, %rdx
	movl	-8(%rbp), %eax
	cltq
	salq	$4, %rax
	addq	%rax, %rdx
	leaq	dist(%rip), %rax
	addq	%rdx, %rax
	movzbl	(%rax), %eax
	movsbl	%al, %eax
	cmpl	%eax, -4(%rbp)
	jge	.L24
	movl	-4(%rbp), %eax
	movl	%eax, %edx
	movl	-44(%rbp), %eax
	movslq	%eax, %rcx
	movl	-8(%rbp), %eax
	cltq
	salq	$4, %rax
	addq	%rax, %rcx
	leaq	dist(%rip), %rax
	addq	%rcx, %rax
	movb	%dl, (%rax)
	movl	-44(%rbp), %eax
	movsbl	%al, %edx
	movl	-4(%rbp), %ecx
	movl	-8(%rbp), %eax
	movl	%ecx, %esi
	movl	%eax, %edi
	call	enq
.L24:
	movl	-28(%rbp), %eax
	subl	-44(%rbp), %eax
	movl	%eax, %edx
	negl	%edx
	cmovs	%eax, %edx
	movl	-32(%rbp), %eax
	addl	%eax, %edx
	movl	-12(%rbp), %eax
	addl	%edx, %eax
	movl	%eax, -4(%rbp)
	movl	-48(%rbp), %eax
	movslq	%eax, %rdx
	movl	-8(%rbp), %eax
	cltq
	salq	$4, %rax
	addq	%rax, %rdx
	leaq	dist(%rip), %rax
	addq	%rdx, %rax
	movzbl	(%rax), %eax
	movsbl	%al, %eax
	cmpl	%eax, -4(%rbp)
	jge	.L23
	movl	-4(%rbp), %eax
	movl	%eax, %edx
	movl	-48(%rbp), %eax
	movslq	%eax, %rcx
	movl	-8(%rbp), %eax
	cltq
	salq	$4, %rax
	addq	%rax, %rcx
	leaq	dist(%rip), %rax
	addq	%rcx, %rax
	movb	%dl, (%rax)
	movl	-48(%rbp), %eax
	movsbl	%al, %edx
	movl	-4(%rbp), %ecx
	movl	-8(%rbp), %eax
	movl	%ecx, %esi
	movl	%eax, %edi
	call	enq
.L23:
	addl	$1, -44(%rbp)
.L22:
	movl	-36(%rbp), %eax
	cmpl	-24(%rbp), %eax
	jl	.L25
.L21:
	addl	$1, -48(%rbp)
.L20:
	movl	-40(%rbp), %eax
	cmpl	-56(%rbp), %eax
	jl	.L26
.L16:
	movl	qsize(%rip), %eax
	testl	%eax, %eax
	jne	.L27
	jmp	.L18
.L29:
	nop
.L18:
	movl	-32(%rbp), %eax
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE9:
	.size	dijkstra, .-dijkstra
	.globl	calc
	.type	calc, @function
calc:
.LFB10:
	.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	$0, -4(%rbp)
	jmp	.L31
.L32:
	movl	-4(%rbp), %eax
	leal	(%rax,%rax), %ecx
	movq	-24(%rbp), %rax
	leaq	1(%rax), %rdx
	movq	%rdx, -24(%rbp)
	movzbl	(%rax), %eax
	cmpb	$66, %al
	sete	%al
	movzbl	%al, %eax
	orl	%ecx, %eax
	movl	%eax, -4(%rbp)
.L31:
	movq	-24(%rbp), %rax
	movzbl	(%rax), %eax
	cmpb	$32, %al
	jg	.L32
	movl	-4(%rbp), %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE10:
	.size	calc, .-calc
	.section	.rodata
.LC0:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB11:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$64, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	jmp	.L35
.L40:
	leaq	-32(%rbp), %rax
	movq	%rax, %rdi
	call	atoi@PLT
	movl	%eax, -44(%rbp)
	movq	stdin(%rip), %rdx
	leaq	-32(%rbp), %rax
	movq	%rax, -40(%rbp)
	movq	-40(%rbp), %rax
	movl	$20, %esi
	movq	%rax, %rdi
	call	fgets@PLT
	movl	$0, -56(%rbp)
	jmp	.L36
.L37:
	movq	-40(%rbp), %rax
	leaq	1(%rax), %rdx
	movq	%rdx, -40(%rbp)
	movzbl	(%rax), %eax
	cmpb	$66, %al
	jne	.L36
	addl	$1, -56(%rbp)
.L36:
	movq	-40(%rbp), %rax
	movzbl	(%rax), %eax
	cmpb	$32, %al
	jg	.L37
	leaq	-32(%rbp), %rax
	movq	%rax, %rdi
	call	calc
	movl	%eax, -52(%rbp)
	movq	stdin(%rip), %rdx
	leaq	-32(%rbp), %rax
	movl	$20, %esi
	movq	%rax, %rdi
	call	fgets@PLT
	leaq	-32(%rbp), %rax
	movq	%rax, %rdi
	call	calc
	movl	%eax, -48(%rbp)
	movl	-44(%rbp), %eax
	subl	-56(%rbp), %eax
	cmpl	%eax, -56(%rbp)
	jle	.L38
	movl	-44(%rbp), %eax
	subl	-56(%rbp), %eax
	movl	%eax, -56(%rbp)
	movl	-52(%rbp), %eax
	notl	%eax
	movl	%eax, %edx
	movl	-44(%rbp), %eax
	movl	$1, %esi
	movl	%eax, %ecx
	sall	%cl, %esi
	movl	%esi, %eax
	subl	$1, %eax
	andl	%edx, %eax
	movl	%eax, -52(%rbp)
	movl	-48(%rbp), %eax
	notl	%eax
	movl	%eax, %edx
	movl	-44(%rbp), %eax
	movl	$1, %esi
	movl	%eax, %ecx
	sall	%cl, %esi
	movl	%esi, %eax
	subl	$1, %eax
	andl	%edx, %eax
	movl	%eax, -48(%rbp)
.L38:
	movl	-48(%rbp), %ecx
	movl	-52(%rbp), %edx
	movl	-56(%rbp), %esi
	movl	-44(%rbp), %eax
	movl	%eax, %edi
	call	dijkstra
	movl	%eax, %esi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L35:
	movq	stdin(%rip), %rdx
	leaq	-32(%rbp), %rax
	movl	$10, %esi
	movq	%rax, %rdi
	call	fgets@PLT
	testq	%rax, %rax
	je	.L39
	movzbl	-32(%rbp), %eax
	cmpb	$48, %al
	jne	.L40
.L39:
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L42
	call	__stack_chk_fail@PLT
.L42:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE11:
	.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	min_heapify
	.type	min_heapify, @function
min_heapify:
.LFB51:
	.cfi_startproc
	endbr64
	leaq	que(%rip), %rax
	movl	qsize(%rip), %r8d
	leaq	4(%rax), %r9
	jmp	.L5
	.p2align 4,,10
	.p2align 3
.L10:
	movslq	%edi, %rcx
	movslq	%esi, %r10
	movzbl	5(%rax,%rcx,8), %r11d
	cmpb	%r11b, 5(%rax,%r10,8)
	jge	.L2
	cmpl	%edx, %r8d
	jg	.L9
	movl	%esi, %edx
.L3:
	cmpl	%edi, %edx
	je	.L1
	movslq	%edx, %rsi
	movzwl	(%r9,%rcx,8), %edi
	movl	(%rax,%rcx,8), %r10d
	movq	(%rax,%rsi,8), %r11
	movq	%r11, (%rax,%rcx,8)
	movl	%r10d, (%rax,%rsi,8)
	movw	%di, (%r9,%rsi,8)
	movl	%edx, %edi
.L5:
	leal	(%rdi,%rdi), %esi
	leal	1(%rsi), %edx
	cmpl	%esi, %r8d
	jg	.L10
.L2:
	cmpl	%edx, %r8d
	jle	.L1
	movslq	%edx, %rsi
	movslq	%edi, %rcx
	movzbl	5(%rax,%rsi,8), %esi
	cmpb	%sil, 5(%rax,%rcx,8)
	jg	.L3
.L1:
	ret
.L9:
	movslq	%edx, %r11
	movzbl	5(%rax,%r10,8), %r10d
	cmpb	%r10b, 5(%rax,%r11,8)
	cmovge	%esi, %edx
	jmp	.L3
	.cfi_endproc
.LFE51:
	.size	min_heapify, .-min_heapify
	.p2align 4
	.globl	deq
	.type	deq, @function
deq:
.LFB52:
	.cfi_startproc
	endbr64
	movl	qsize(%rip), %eax
	leaq	que(%rip), %rdx
	xorl	%edi, %edi
	subl	$1, %eax
	movl	%eax, qsize(%rip)
	cltq
	movq	(%rdx,%rax,8), %rax
	movq	%rax, que(%rip)
	jmp	min_heapify
	.cfi_endproc
.LFE52:
	.size	deq, .-deq
	.p2align 4
	.globl	enq
	.type	enq, @function
enq:
.LFB53:
	.cfi_startproc
	endbr64
	movl	%esi, %r8d
	movslq	qsize(%rip), %rsi
	movl	%edx, %r9d
	xorl	%edx, %edx
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset 3, -16
	movb	%r9b, %dl
	movl	%r8d, %ebx
	leal	1(%rsi), %eax
	movb	%bl, %dh
	movl	%eax, qsize(%rip)
	leaq	que(%rip), %rax
	leaq	4(%rax), %r10
	movl	%edi, (%rax,%rsi,8)
	movw	%dx, (%r10,%rsi,8)
	testl	%esi, %esi
	jle	.L12
	movzbl	5(%rax,%rsi,8), %edi
	movq	%rsi, %rcx
	jmp	.L14
	.p2align 4,,10
	.p2align 3
.L16:
	movslq	%edx, %r11
	xorl	%ebx, %ebx
	movq	(%rax,%rsi,8), %r9
	movl	%edi, %edx
	movb	4(%rax,%r11,8), %bl
	movl	(%rax,%r11,8), %r8d
	movq	%r9, (%rax,%r11,8)
	movb	%dl, %bh
	movl	%r8d, (%rax,%rsi,8)
	movw	%bx, (%r10,%rsi,8)
	testl	%ecx, %ecx
	je	.L12
.L14:
	movl	%ecx, %edx
	sarl	%ecx
	movslq	%ecx, %rsi
	cmpb	%dil, 5(%rax,%rsi,8)
	jg	.L16
.L12:
	popq	%rbx
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE53:
	.size	enq, .-enq
	.p2align 4
	.globl	dijkstra
	.type	dijkstra, @function
dijkstra:
.LFB54:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	movl	%edi, %r15d
	leaq	dist(%rip), %rdi
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	movl	%esi, %r14d
	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
	movl	%edx, %ebx
	movl	$1048576, %edx
	subq	$56, %rsp
	.cfi_def_cfa_offset 112
	movl	%esi, 32(%rsp)
	movl	$75, %esi
	movl	%ecx, 44(%rsp)
	call	memset@PLT
	movl	%r15d, %eax
	movl	$0, qsize(%rip)
	subl	%r14d, %eax
	movl	%eax, (%rsp)
	testl	%r15d, %r15d
	jle	.L38
	movslq	%ebx, %rax
	leaq	dist(%rip), %rsi
	xorl	%edi, %edi
	movl	%ebx, que(%rip)
	salq	$4, %rax
	movw	%di, 4+que(%rip)
	leaq	que(%rip), %r13
	movb	$0, (%rsi,%rax)
	cmpl	$1, %r15d
	je	.L23
	leaq	1(%rsi,%rax), %r10
	leaq	8(%r13), %r9
	movl	$1, %r8d
	.p2align 4,,10
	.p2align 3
.L26:
	movl	%r8d, %eax
	movl	%r8d, %ecx
	movb	$0, (%r10)
	addl	$1, %r8d
	movl	%ebx, (%r9)
	movb	$0, 5(%r9)
	movb	%al, 4(%r9)
	jmp	.L25
	.p2align 4,,10
	.p2align 3
.L58:
	movq	0(%r13,%rax,8), %r11
	movl	0(%r13,%rdx,8), %edi
	movzbl	4(%r13,%rdx,8), %esi
	movq	%r11, 0(%r13,%rdx,8)
	movl	%edi, 0(%r13,%rax,8)
	movb	%sil, 4(%r13,%rax,8)
	movb	$0, 5(%r13,%rax,8)
	testl	%ecx, %ecx
	je	.L24
.L25:
	movslq	%ecx, %rdx
	sarl	%ecx
	movslq	%ecx, %rax
	cmpb	$0, 5(%r13,%rax,8)
	jg	.L58
.L24:
	addq	$1, %r10
	addq	$8, %r9
	cmpl	%r8d, %r15d
	jne	.L26
.L23:
	leaq	4+que(%rip), %r14
	jmp	.L37
	.p2align 4,,10
	.p2align 3
.L27:
	testl	%r15d, %r15d
	je	.L21
.L37:
	movsbl	5+que(%rip), %eax
	movl	0(%r13), %r11d
	xorl	%edi, %edi
	movsbl	4+que(%rip), %ebp
	movl	%eax, 4(%rsp)
	movl	%eax, %ebx
	leal	-1(%r15), %eax
	movl	%eax, qsize(%rip)
	cltq
	movq	0(%r13,%rax,8), %rax
	movl	%r11d, 8(%rsp)
	movq	%rax, 0(%r13)
	call	min_heapify
	movl	8(%rsp), %r11d
	cmpl	44(%rsp), %r11d
	je	.L21
	movslq	%r11d, %rax
	leaq	dist(%rip), %rdi
	movslq	%ebp, %rdx
	movl	qsize(%rip), %r15d
	salq	$4, %rax
	addq	%rdi, %rax
	cmpb	(%rax,%rdx), %bl
	jg	.L27
	movl	32(%rsp), %ecx
	testl	%ecx, %ecx
	jle	.L27
	movl	$0, 12(%rsp)
	xorl	%r12d, %r12d
	jmp	.L36
	.p2align 4,,10
	.p2align 3
.L28:
	movl	32(%rsp), %edi
	addl	$1, %r12d
	subl	$1, %ebp
	cmpl	%edi, 12(%rsp)
	jge	.L27
.L36:
	btl	%r12d, %r11d
	jnc	.L28
	movl	%ebp, %eax
	movl	(%rsp), %edx
	addl	$1, 12(%rsp)
	negl	%eax
	cmovs	%ebp, %eax
	testl	%edx, %edx
	jle	.L28
	addl	4(%rsp), %eax
	movl	%r11d, %edi
	movl	%r12d, %esi
	movl	%ebp, 8(%rsp)
	movl	%eax, 20(%rsp)
	btcl	%r12d, %edi
	movslq	%r12d, %rax
	negl	%esi
	movl	%edi, 16(%rsp)
	xorl	%r10d, %r10d
	movl	%r11d, %ebp
	movq	%rax, 24(%rsp)
	jmp	.L35
	.p2align 4,,10
	.p2align 3
.L30:
	movl	8(%rsp), %edx
	leaq	dist(%rip), %rbx
	subl	%esi, %edx
	movl	%edx, %eax
	negl	%eax
	cmovs	%edx, %eax
	salq	$4, %rdi
	addl	4(%rsp), %eax
	addq	%rbx, %rdi
	addq	24(%rsp), %rdi
	addl	%r9d, %eax
	movsbl	(%rdi), %edx
	cmpl	%eax, %edx
	jg	.L59
.L29:
	addl	$1, %esi
	cmpl	(%rsp), %r10d
	jge	.L60
.L35:
	leal	(%rsi,%r12), %edx
	btl	%edx, %ebp
	jc	.L29
	movl	16(%rsp), %r11d
	movl	%esi, %r9d
	addl	$1, %r10d
	movl	20(%rsp), %eax
	negl	%r9d
	leaq	dist(%rip), %rbx
	cmovs	%esi, %r9d
	btcl	%edx, %r11d
	movslq	%edx, %rdx
	movslq	%r11d, %rdi
	movq	%rdi, %rcx
	addl	%r9d, %eax
	salq	$4, %rcx
	addq	%rbx, %rcx
	addq	%rcx, %rdx
	movsbl	(%rdx), %ecx
	cmpl	%eax, %ecx
	jle	.L30
	movb	%al, (%rdx)
	leal	(%r12,%rsi), %r8d
	xorl	%edx, %edx
	leal	1(%r15), %ecx
	movb	%r8b, %dl
	movl	%ecx, qsize(%rip)
	movl	%eax, %ebx
	movl	%ecx, 36(%rsp)
	movb	%al, %dh
	movslq	%r15d, %rcx
	movl	%r11d, 0(%r13,%rcx,8)
	movw	%dx, (%r14,%rcx,8)
	testl	%r15d, %r15d
	jle	.L57
	movl	%esi, 40(%rsp)
	jmp	.L31
	.p2align 4,,10
	.p2align 3
.L32:
	xorl	%ecx, %ecx
	movb	4(%r13,%rax,8), %cl
	movl	0(%r13,%rax,8), %r8d
	movq	0(%r13,%rdx,8), %rsi
	movb	%bl, %ch
	movq	%rsi, 0(%r13,%rax,8)
	movl	%r8d, 0(%r13,%rdx,8)
	movw	%cx, (%r14,%rdx,8)
	testl	%r15d, %r15d
	je	.L39
.L31:
	movslq	%r15d, %rax
	sarl	%r15d
	movslq	%r15d, %rdx
	cmpb	5(%r13,%rdx,8), %bl
	jl	.L32
.L39:
	movl	40(%rsp), %esi
.L57:
	movl	36(%rsp), %r15d
	jmp	.L30
	.p2align 4,,10
	.p2align 3
.L59:
	xorl	%ecx, %ecx
	movb	%al, (%rdi)
	movslq	%r15d, %rdx
	leal	1(%r15), %edi
	movb	%r12b, %cl
	movl	%edi, qsize(%rip)
	movl	%eax, %ebx
	movb	%al, %ch
	movl	%r11d, 0(%r13,%rdx,8)
	movw	%cx, (%r14,%rdx,8)
	testl	%r15d, %r15d
	jg	.L33
	jmp	.L40
	.p2align 4,,10
	.p2align 3
.L34:
	xorl	%ecx, %ecx
	movb	4(%r13,%rax,8), %cl
	movl	0(%r13,%rax,8), %r8d
	movq	0(%r13,%rdx,8), %r9
	movb	%bl, %ch
	movq	%r9, 0(%r13,%rax,8)
	movl	%r8d, 0(%r13,%rdx,8)
	movw	%cx, (%r14,%rdx,8)
	testl	%r15d, %r15d
	je	.L40
.L33:
	movslq	%r15d, %rax
	sarl	%r15d
	movslq	%r15d, %rdx
	cmpb	5(%r13,%rdx,8), %bl
	jl	.L34
.L40:
	movl	%edi, %r15d
	addl	$1, %esi
	cmpl	(%rsp), %r10d
	jl	.L35
	.p2align 4,,10
	.p2align 3
.L60:
	movl	%ebp, %r11d
	movl	8(%rsp), %ebp
	jmp	.L28
.L38:
	movl	$-1, 4(%rsp)
.L21:
	movl	4(%rsp), %eax
	addq	$56, %rsp
	.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
	.cfi_endproc
.LFE54:
	.size	dijkstra, .-dijkstra
	.p2align 4
	.globl	calc
	.type	calc, @function
calc:
.LFB55:
	.cfi_startproc
	endbr64
	movzbl	(%rdi), %edx
	xorl	%eax, %eax
	cmpb	$32, %dl
	jle	.L64
	.p2align 4,,10
	.p2align 3
.L63:
	addl	%eax, %eax
	addq	$1, %rdi
	cmpb	$66, %dl
	sete	%dl
	movzbl	%dl, %edx
	orl	%edx, %eax
	movzbl	(%rdi), %edx
	cmpb	$32, %dl
	jg	.L63
	ret
	.p2align 4,,10
	.p2align 3
.L64:
	ret
	.cfi_endproc
.LFE55:
	.size	calc, .-calc
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB56:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	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	$40, %rsp
	.cfi_def_cfa_offset 96
	movq	%fs:40, %rax
	movq	%rax, 24(%rsp)
	xorl	%eax, %eax
	movq	%rsp, %rbx
	.p2align 4,,10
	.p2align 3
.L67:
	movq	stdin(%rip), %rdx
	movl	$10, %esi
	movq	%rbx, %rdi
	call	fgets@PLT
	testq	%rax, %rax
	je	.L75
	cmpb	$48, (%rsp)
	je	.L75
	movl	$10, %edx
	xorl	%esi, %esi
	movq	%rbx, %rdi
	call	strtol@PLT
	movq	stdin(%rip), %rdx
	movl	$20, %esi
	movq	%rbx, %rdi
	movq	%rax, %rbp
	movl	%eax, %r13d
	call	fgets@PLT
	movzbl	(%rsp), %eax
	cmpb	$32, %al
	jle	.L78
	movl	%eax, %ecx
	movq	%rbx, %rdx
	xorl	%r15d, %r15d
	.p2align 4,,10
	.p2align 3
.L70:
	addq	$1, %rdx
	cmpb	$66, %cl
	sete	%cl
	movzbl	%cl, %ecx
	addl	%ecx, %r15d
	movzbl	(%rdx), %ecx
	cmpb	$32, %cl
	jg	.L70
	movq	%rbx, %rdx
	xorl	%r12d, %r12d
	.p2align 4,,10
	.p2align 3
.L71:
	addl	%r12d, %r12d
	addq	$1, %rdx
	cmpb	$66, %al
	sete	%al
	movzbl	%al, %eax
	orl	%eax, %r12d
	movzbl	(%rdx), %eax
	cmpb	$32, %al
	jg	.L71
	movl	%ebp, %r14d
	subl	%r15d, %r14d
.L68:
	movq	stdin(%rip), %rdx
	movl	$20, %esi
	movq	%rbx, %rdi
	call	fgets@PLT
	movzbl	(%rsp), %eax
	cmpb	$32, %al
	jle	.L79
	movq	%rbx, %rdx
	xorl	%r8d, %r8d
	.p2align 4,,10
	.p2align 3
.L73:
	addl	%r8d, %r8d
	addq	$1, %rdx
	cmpb	$66, %al
	sete	%al
	movzbl	%al, %eax
	orl	%eax, %r8d
	movzbl	(%rdx), %eax
	cmpb	$32, %al
	jg	.L73
.L72:
	cmpl	%r14d, %r15d
	jle	.L74
	movl	$1, %eax
	movl	%ebp, %ecx
	notl	%r12d
	notl	%r8d
	sall	%cl, %eax
	movl	%r14d, %r15d
	subl	$1, %eax
	andl	%eax, %r12d
	andl	%eax, %r8d
.L74:
	movl	%r12d, %edx
	movl	%r15d, %esi
	movl	%r13d, %edi
	movl	%r8d, %ecx
	call	dijkstra
	leaq	.LC0(%rip), %rsi
	movl	$1, %edi
	movl	%eax, %edx
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L67
	.p2align 4,,10
	.p2align 3
.L75:
	movq	24(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L87
	addq	$40, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 56
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L79:
	.cfi_restore_state
	xorl	%r8d, %r8d
	jmp	.L72
	.p2align 4,,10
	.p2align 3
.L78:
	movl	%ebp, %r14d
	xorl	%r15d, %r15d
	xorl	%r12d, %r12d
	jmp	.L68
.L87:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE56:
	.size	main, .-main
	.globl	dist
	.bss
	.align 32
	.type	dist, @object
	.size	dist, 1048576
dist:
	.zero	1048576
	.globl	qmax
	.align 4
	.type	qmax, @object
	.size	qmax, 4
qmax:
	.zero	4
	.globl	qsize
	.align 4
	.type	qsize, @object
	.size	qsize, 4
qsize:
	.zero	4
	.globl	que
	.align 32
	.type	que, @object
	.size	que, 2400000
que:
	.zero	2400000
	.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	min_heapify
	.type	min_heapify, @function
min_heapify:
.LFB51:
	.cfi_startproc
	endbr64
	leaq	que(%rip), %rax
	movl	qsize(%rip), %r8d
	leaq	4(%rax), %r9
	jmp	.L5
	.p2align 4,,10
	.p2align 3
.L10:
	movslq	%edi, %rcx
	movslq	%esi, %r10
	movzbl	5(%rax,%rcx,8), %r11d
	cmpb	%r11b, 5(%rax,%r10,8)
	jge	.L2
	cmpl	%edx, %r8d
	jg	.L9
	movl	%esi, %edx
.L3:
	cmpl	%edi, %edx
	je	.L1
	movslq	%edx, %rsi
	movzwl	(%r9,%rcx,8), %edi
	movl	(%rax,%rcx,8), %r10d
	movq	(%rax,%rsi,8), %r11
	movq	%r11, (%rax,%rcx,8)
	movl	%r10d, (%rax,%rsi,8)
	movw	%di, (%r9,%rsi,8)
	movl	%edx, %edi
.L5:
	leal	(%rdi,%rdi), %esi
	leal	1(%rsi), %edx
	cmpl	%esi, %r8d
	jg	.L10
.L2:
	cmpl	%edx, %r8d
	jle	.L1
	movslq	%edx, %rsi
	movslq	%edi, %rcx
	movzbl	5(%rax,%rsi,8), %esi
	cmpb	%sil, 5(%rax,%rcx,8)
	jg	.L3
.L1:
	ret
.L9:
	movslq	%edx, %r11
	movzbl	5(%rax,%r10,8), %r10d
	cmpb	%r10b, 5(%rax,%r11,8)
	cmovge	%esi, %edx
	jmp	.L3
	.cfi_endproc
.LFE51:
	.size	min_heapify, .-min_heapify
	.p2align 4
	.globl	deq
	.type	deq, @function
deq:
.LFB52:
	.cfi_startproc
	endbr64
	movl	qsize(%rip), %eax
	leaq	que(%rip), %rdx
	xorl	%edi, %edi
	subl	$1, %eax
	movl	%eax, qsize(%rip)
	cltq
	movq	(%rdx,%rax,8), %rax
	movq	%rax, que(%rip)
	jmp	min_heapify
	.cfi_endproc
.LFE52:
	.size	deq, .-deq
	.p2align 4
	.globl	enq
	.type	enq, @function
enq:
.LFB53:
	.cfi_startproc
	endbr64
	movl	%esi, %r8d
	movslq	qsize(%rip), %rsi
	movl	%edx, %r9d
	xorl	%edx, %edx
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset 3, -16
	movb	%r9b, %dl
	movl	%r8d, %ebx
	leal	1(%rsi), %eax
	movb	%bl, %dh
	movl	%eax, qsize(%rip)
	leaq	que(%rip), %rax
	leaq	4(%rax), %r10
	movl	%edi, (%rax,%rsi,8)
	movw	%dx, (%r10,%rsi,8)
	testl	%esi, %esi
	jle	.L12
	movzbl	5(%rax,%rsi,8), %edi
	movq	%rsi, %rcx
	jmp	.L14
	.p2align 4,,10
	.p2align 3
.L16:
	movslq	%edx, %r11
	xorl	%ebx, %ebx
	movq	(%rax,%rsi,8), %r9
	movl	%edi, %edx
	movb	4(%rax,%r11,8), %bl
	movl	(%rax,%r11,8), %r8d
	movq	%r9, (%rax,%r11,8)
	movb	%dl, %bh
	movl	%r8d, (%rax,%rsi,8)
	movw	%bx, (%r10,%rsi,8)
	testl	%ecx, %ecx
	je	.L12
.L14:
	movl	%ecx, %edx
	sarl	%ecx
	movslq	%ecx, %rsi
	cmpb	%dil, 5(%rax,%rsi,8)
	jg	.L16
.L12:
	popq	%rbx
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE53:
	.size	enq, .-enq
	.p2align 4
	.globl	dijkstra
	.type	dijkstra, @function
dijkstra:
.LFB54:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	movl	%edi, %r15d
	leaq	dist(%rip), %rdi
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	movl	%esi, %r14d
	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
	movl	%edx, %ebx
	movl	$1048576, %edx
	subq	$56, %rsp
	.cfi_def_cfa_offset 112
	movl	%esi, 32(%rsp)
	movl	$75, %esi
	movl	%ecx, 44(%rsp)
	call	memset@PLT
	movl	%r15d, %eax
	movl	$0, qsize(%rip)
	subl	%r14d, %eax
	movl	%eax, (%rsp)
	testl	%r15d, %r15d
	jle	.L38
	movslq	%ebx, %rax
	leaq	dist(%rip), %rsi
	xorl	%edi, %edi
	movl	%ebx, que(%rip)
	salq	$4, %rax
	movw	%di, 4+que(%rip)
	leaq	que(%rip), %r13
	movb	$0, (%rsi,%rax)
	cmpl	$1, %r15d
	je	.L23
	leaq	1(%rsi,%rax), %r10
	leaq	8(%r13), %r9
	movl	$1, %r8d
	.p2align 4,,10
	.p2align 3
.L26:
	movl	%r8d, %eax
	movl	%r8d, %ecx
	movb	$0, (%r10)
	addl	$1, %r8d
	movl	%ebx, (%r9)
	movb	$0, 5(%r9)
	movb	%al, 4(%r9)
	jmp	.L25
	.p2align 4,,10
	.p2align 3
.L58:
	movq	0(%r13,%rax,8), %r11
	movl	0(%r13,%rdx,8), %edi
	movzbl	4(%r13,%rdx,8), %esi
	movq	%r11, 0(%r13,%rdx,8)
	movl	%edi, 0(%r13,%rax,8)
	movb	%sil, 4(%r13,%rax,8)
	movb	$0, 5(%r13,%rax,8)
	testl	%ecx, %ecx
	je	.L24
.L25:
	movslq	%ecx, %rdx
	sarl	%ecx
	movslq	%ecx, %rax
	cmpb	$0, 5(%r13,%rax,8)
	jg	.L58
.L24:
	addq	$1, %r10
	addq	$8, %r9
	cmpl	%r8d, %r15d
	jne	.L26
.L23:
	leaq	4+que(%rip), %r14
	jmp	.L37
	.p2align 4,,10
	.p2align 3
.L27:
	testl	%r15d, %r15d
	je	.L21
.L37:
	movsbl	5+que(%rip), %eax
	movl	0(%r13), %r11d
	xorl	%edi, %edi
	movsbl	4+que(%rip), %ebp
	movl	%eax, 4(%rsp)
	movl	%eax, %ebx
	leal	-1(%r15), %eax
	movl	%eax, qsize(%rip)
	cltq
	movq	0(%r13,%rax,8), %rax
	movl	%r11d, 8(%rsp)
	movq	%rax, 0(%r13)
	call	min_heapify
	movl	8(%rsp), %r11d
	cmpl	44(%rsp), %r11d
	je	.L21
	movslq	%r11d, %rax
	leaq	dist(%rip), %rdi
	movslq	%ebp, %rdx
	movl	qsize(%rip), %r15d
	salq	$4, %rax
	addq	%rdi, %rax
	cmpb	(%rax,%rdx), %bl
	jg	.L27
	movl	32(%rsp), %ecx
	testl	%ecx, %ecx
	jle	.L27
	movl	$0, 12(%rsp)
	xorl	%r12d, %r12d
	jmp	.L36
	.p2align 4,,10
	.p2align 3
.L28:
	movl	32(%rsp), %edi
	addl	$1, %r12d
	subl	$1, %ebp
	cmpl	%edi, 12(%rsp)
	jge	.L27
.L36:
	btl	%r12d, %r11d
	jnc	.L28
	movl	%ebp, %eax
	movl	(%rsp), %edx
	addl	$1, 12(%rsp)
	negl	%eax
	cmovs	%ebp, %eax
	testl	%edx, %edx
	jle	.L28
	addl	4(%rsp), %eax
	movl	%r11d, %edi
	movl	%r12d, %esi
	movl	%ebp, 8(%rsp)
	movl	%eax, 20(%rsp)
	btcl	%r12d, %edi
	movslq	%r12d, %rax
	negl	%esi
	movl	%edi, 16(%rsp)
	xorl	%r10d, %r10d
	movl	%r11d, %ebp
	movq	%rax, 24(%rsp)
	jmp	.L35
	.p2align 4,,10
	.p2align 3
.L30:
	movl	8(%rsp), %edx
	leaq	dist(%rip), %rbx
	subl	%esi, %edx
	movl	%edx, %eax
	negl	%eax
	cmovs	%edx, %eax
	salq	$4, %rdi
	addl	4(%rsp), %eax
	addq	%rbx, %rdi
	addq	24(%rsp), %rdi
	addl	%r9d, %eax
	movsbl	(%rdi), %edx
	cmpl	%eax, %edx
	jg	.L59
.L29:
	addl	$1, %esi
	cmpl	(%rsp), %r10d
	jge	.L60
.L35:
	leal	(%rsi,%r12), %edx
	btl	%edx, %ebp
	jc	.L29
	movl	16(%rsp), %r11d
	movl	%esi, %r9d
	addl	$1, %r10d
	movl	20(%rsp), %eax
	negl	%r9d
	leaq	dist(%rip), %rbx
	cmovs	%esi, %r9d
	btcl	%edx, %r11d
	movslq	%edx, %rdx
	movslq	%r11d, %rdi
	movq	%rdi, %rcx
	addl	%r9d, %eax
	salq	$4, %rcx
	addq	%rbx, %rcx
	addq	%rcx, %rdx
	movsbl	(%rdx), %ecx
	cmpl	%eax, %ecx
	jle	.L30
	movb	%al, (%rdx)
	leal	(%r12,%rsi), %r8d
	xorl	%edx, %edx
	leal	1(%r15), %ecx
	movb	%r8b, %dl
	movl	%ecx, qsize(%rip)
	movl	%eax, %ebx
	movl	%ecx, 36(%rsp)
	movb	%al, %dh
	movslq	%r15d, %rcx
	movl	%r11d, 0(%r13,%rcx,8)
	movw	%dx, (%r14,%rcx,8)
	testl	%r15d, %r15d
	jle	.L57
	movl	%esi, 40(%rsp)
	jmp	.L31
	.p2align 4,,10
	.p2align 3
.L32:
	xorl	%ecx, %ecx
	movb	4(%r13,%rax,8), %cl
	movl	0(%r13,%rax,8), %r8d
	movq	0(%r13,%rdx,8), %rsi
	movb	%bl, %ch
	movq	%rsi, 0(%r13,%rax,8)
	movl	%r8d, 0(%r13,%rdx,8)
	movw	%cx, (%r14,%rdx,8)
	testl	%r15d, %r15d
	je	.L39
.L31:
	movslq	%r15d, %rax
	sarl	%r15d
	movslq	%r15d, %rdx
	cmpb	5(%r13,%rdx,8), %bl
	jl	.L32
.L39:
	movl	40(%rsp), %esi
.L57:
	movl	36(%rsp), %r15d
	jmp	.L30
	.p2align 4,,10
	.p2align 3
.L59:
	xorl	%ecx, %ecx
	movb	%al, (%rdi)
	movslq	%r15d, %rdx
	leal	1(%r15), %edi
	movb	%r12b, %cl
	movl	%edi, qsize(%rip)
	movl	%eax, %ebx
	movb	%al, %ch
	movl	%r11d, 0(%r13,%rdx,8)
	movw	%cx, (%r14,%rdx,8)
	testl	%r15d, %r15d
	jg	.L33
	jmp	.L40
	.p2align 4,,10
	.p2align 3
.L34:
	xorl	%ecx, %ecx
	movb	4(%r13,%rax,8), %cl
	movl	0(%r13,%rax,8), %r8d
	movq	0(%r13,%rdx,8), %r9
	movb	%bl, %ch
	movq	%r9, 0(%r13,%rax,8)
	movl	%r8d, 0(%r13,%rdx,8)
	movw	%cx, (%r14,%rdx,8)
	testl	%r15d, %r15d
	je	.L40
.L33:
	movslq	%r15d, %rax
	sarl	%r15d
	movslq	%r15d, %rdx
	cmpb	5(%r13,%rdx,8), %bl
	jl	.L34
.L40:
	movl	%edi, %r15d
	addl	$1, %esi
	cmpl	(%rsp), %r10d
	jl	.L35
	.p2align 4,,10
	.p2align 3
.L60:
	movl	%ebp, %r11d
	movl	8(%rsp), %ebp
	jmp	.L28
.L38:
	movl	$-1, 4(%rsp)
.L21:
	movl	4(%rsp), %eax
	addq	$56, %rsp
	.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
	.cfi_endproc
.LFE54:
	.size	dijkstra, .-dijkstra
	.p2align 4
	.globl	calc
	.type	calc, @function
calc:
.LFB55:
	.cfi_startproc
	endbr64
	movzbl	(%rdi), %edx
	xorl	%eax, %eax
	cmpb	$32, %dl
	jle	.L64
	.p2align 4,,10
	.p2align 3
.L63:
	addl	%eax, %eax
	addq	$1, %rdi
	cmpb	$66, %dl
	sete	%dl
	movzbl	%dl, %edx
	orl	%edx, %eax
	movzbl	(%rdi), %edx
	cmpb	$32, %dl
	jg	.L63
	ret
	.p2align 4,,10
	.p2align 3
.L64:
	ret
	.cfi_endproc
.LFE55:
	.size	calc, .-calc
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB56:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	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	$40, %rsp
	.cfi_def_cfa_offset 96
	movq	%fs:40, %rax
	movq	%rax, 24(%rsp)
	xorl	%eax, %eax
	movq	%rsp, %rbx
	.p2align 4,,10
	.p2align 3
.L67:
	movq	stdin(%rip), %rdx
	movl	$10, %esi
	movq	%rbx, %rdi
	call	fgets@PLT
	testq	%rax, %rax
	je	.L75
	cmpb	$48, (%rsp)
	je	.L75
	movl	$10, %edx
	xorl	%esi, %esi
	movq	%rbx, %rdi
	call	strtol@PLT
	movq	stdin(%rip), %rdx
	movl	$20, %esi
	movq	%rbx, %rdi
	movq	%rax, %rbp
	movl	%eax, %r13d
	call	fgets@PLT
	movzbl	(%rsp), %eax
	cmpb	$32, %al
	jle	.L78
	movl	%eax, %ecx
	movq	%rbx, %rdx
	xorl	%r15d, %r15d
	.p2align 4,,10
	.p2align 3
.L70:
	addq	$1, %rdx
	cmpb	$66, %cl
	sete	%cl
	movzbl	%cl, %ecx
	addl	%ecx, %r15d
	movzbl	(%rdx), %ecx
	cmpb	$32, %cl
	jg	.L70
	movq	%rbx, %rdx
	xorl	%r12d, %r12d
	.p2align 4,,10
	.p2align 3
.L71:
	addl	%r12d, %r12d
	addq	$1, %rdx
	cmpb	$66, %al
	sete	%al
	movzbl	%al, %eax
	orl	%eax, %r12d
	movzbl	(%rdx), %eax
	cmpb	$32, %al
	jg	.L71
	movl	%ebp, %r14d
	subl	%r15d, %r14d
.L68:
	movq	stdin(%rip), %rdx
	movl	$20, %esi
	movq	%rbx, %rdi
	call	fgets@PLT
	movzbl	(%rsp), %eax
	cmpb	$32, %al
	jle	.L79
	movq	%rbx, %rdx
	xorl	%r8d, %r8d
	.p2align 4,,10
	.p2align 3
.L73:
	addl	%r8d, %r8d
	addq	$1, %rdx
	cmpb	$66, %al
	sete	%al
	movzbl	%al, %eax
	orl	%eax, %r8d
	movzbl	(%rdx), %eax
	cmpb	$32, %al
	jg	.L73
.L72:
	cmpl	%r14d, %r15d
	jle	.L74
	movl	$1, %eax
	movl	%ebp, %ecx
	notl	%r12d
	notl	%r8d
	sall	%cl, %eax
	movl	%r14d, %r15d
	subl	$1, %eax
	andl	%eax, %r12d
	andl	%eax, %r8d
.L74:
	movl	%r12d, %edx
	movl	%r15d, %esi
	movl	%r13d, %edi
	movl	%r8d, %ecx
	call	dijkstra
	leaq	.LC0(%rip), %rsi
	movl	$1, %edi
	movl	%eax, %edx
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L67
	.p2align 4,,10
	.p2align 3
.L75:
	movq	24(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L87
	addq	$40, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 56
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L79:
	.cfi_restore_state
	xorl	%r8d, %r8d
	jmp	.L72
	.p2align 4,,10
	.p2align 3
.L78:
	movl	%ebp, %r14d
	xorl	%r15d, %r15d
	xorl	%r12d, %r12d
	jmp	.L68
.L87:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE56:
	.size	main, .-main
	.globl	dist
	.bss
	.align 32
	.type	dist, @object
	.size	dist, 1048576
dist:
	.zero	1048576
	.globl	qmax
	.align 4
	.type	qmax, @object
	.size	qmax, 4
qmax:
	.zero	4
	.globl	qsize
	.align 4
	.type	qsize, @object
	.size	qsize, 4
qsize:
	.zero	4
	.globl	que
	.align 32
	.type	que, @object
	.size	que, 2400000
que:
	.zero	2400000
	.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:

// AOJ 2040 Sort the Panels
// 2018.3.13 bal4u

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

#define QMAX 300000
typedef struct { int s; char p; char t; } QUE;
QUE que[QMAX]; int qsize, qmax;

#define PARENT(i) ((i)>>1)
#define LEFT(i)   ((i)<<1)
#define RIGHT(i)  (((i)<<1)+1)

void min_heapify(int i)
{
	int l, r, min;
	QUE qt;

	l = LEFT(i), r = RIGHT(i);
	if (l < qsize && que[l].t < que[i].t) min = l; else min = i;
	if (r < qsize && que[r].t < que[min].t) min = r;
	if (min != i) {
		qt = que[i], que[i] = que[min], que[min] = qt;
		min_heapify(min);
	}
}

void deq()
{
	que[0] = que[--qsize];
	min_heapify(0);
}

void enq(int s, int t, char p)
{
	int i, min;
	QUE qt;

	i = qsize++;
	que[i].s = s, que[i].t = t, que[i].p = p;
	while (i > 0 && que[min = PARENT(i)].t > que[i].t) {
		qt = que[i], que[i] = que[min], que[min] = qt;
		i = min;
	}
}

#define ABS(a)  ((a)>=0?(a):-(a))
char dist[1<<16][16];

int dijkstra(int n, int nb, int start, int goal)
{
	int i, j, k, m, s, t, p, ns, nt, nw;
	int pi, ij;

	memset(dist, 75, sizeof(dist));
	qsize = 0;
	t = -1, nw = n - nb;
	for (p = 0; p < n; p++) dist[start][p] = 0, enq(start, 0, p);
	while (qsize) {
		s = que[0].s, t = que[0].t, p = que[0].p, deq();
		if (s == goal) break;

		if (dist[s][p] < t) continue;

		for (k = i = 0; k < nb; i++) if (s & (1<<i)) { k++, pi = ABS(p-i);
			for (m = j = 0; m < nw; j++) if (!(s & (1<<j))) { m++;
				ij = ABS(j-i);
				ns = s ^ (1<<i) ^ (1<<j);
				nt = t + pi+ij;
				if (dist[ns][j] > nt) dist[ns][j] = nt, enq(ns, nt, j);
				nt = t + ABS(p-j)+ij;
				if (dist[ns][i] > nt) dist[ns][i] = nt, enq(ns, nt, i);
			}
		}
	}
	return t;
}

int calc(char *s) { int res=0; while (*s > ' ') res = (res<<1)|(*s++ == 'B'); return res; }

int main()
{
	int n, nb, start, goal;
	char buf[20], *p;

	while (fgets(buf, 10, stdin) && *buf != '0') {
		n = atoi(buf);
		fgets(p=buf, 20, stdin); nb = 0; while (*p > ' ') if (*p++ == 'B') nb++;
		start = calc(buf);
		fgets(buf, 20, stdin), goal = calc(buf);
		if (nb > n-nb) {
			nb = n-nb;
			start = ~start & ((1<<n)-1), goal = ~goal & ((1<<n)-1);
		}
		printf("%d\n", dijkstra(n, nb, start, goal));
	}
	return 0;
}

4
WBWB
BWBW
8
WWWWBWBB
BWBBWWWW
0
 4
BWBW
BWBW
8
WWWWBWBB
WWBBWBWW
0
 4
BBWW
BWBW
8
WWWWBWBB
WWBBWBWW
0
 4
BBWW
WBWB
8
WWWWBWBB
WWBBWBWW
0
 4
WBWB
BWBW
13
WWWWBWBB
WBBBWWWW
0
 4
WBWB
BWBW
8
BBWBWWWW
WWBBWBWW
0
 4
WBWB
BWBW
8
WBWWBWWB
WWBBWBWW
0
 4
WBWB
BWBW
9
WWWBBWWB
BWBBWWWW
0
 4
WBBW
BWBW
8
WWWWBWBB
WWBWBBWW
0
 4
WBWB
WBWB
13
WWWWBWBB
WBBBWWWW
0

3
14
 0
9
 1
9
 3
9
 3
13
 3
7
 3
6
 3
11
 1
7
 0
13

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

```c
// AOJ 2040 Sort the Panels
// 2018.3.13 bal4u

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

#define QMAX 300000
typedef struct { int s; char p; char t; } QUE;
QUE que[QMAX]; int qsize, qmax;

#define PARENT(i) ((i)>>1)
#define LEFT(i)   ((i)<<1)
#define RIGHT(i)  (((i)<<1)+1)

void min_heapify(int i)
{
	int l, r, min;
	QUE qt;

	l = LEFT(i), r = RIGHT(i);
	if (l < qsize && que[l].t < que[i].t) min = l; else min = i;
	if (r < qsize && que[r].t < que[min].t) min = r;
	if (min != i) {
		qt = que[i], que[i] = que[min], que[min] = qt;
		min_heapify(min);
	}
}

void deq()
{
	que[0] = que[--qsize];
	min_heapify(0);
}

void enq(int s, int t, char p)
{
	int i, min;
	QUE qt;

	i = qsize++;
	que[i].s = s, que[i].t = t, que[i].p = p;
	while (i > 0 && que[min = PARENT(i)].t > que[i].t) {
		qt = que[i], que[i] = que[min], que[min] = qt;
		i = min;
	}
}

#define ABS(a)  ((a)>=0?(a):-(a))
char dist[1<<16][16];

int dijkstra(int n, int nb, int start, int goal)
{
	int i, j, k, m, s, t, p, ns, nt, nw;
	int pi, ij;

	memset(dist, 75, sizeof(dist));
	qsize = 0;
	t = -1, nw = n - nb;
	for (p = 0; p < n; p++) dist[start][p] = 0, enq(start, 0, p);
	while (qsize) {
		s = que[0].s, t = que[0].t, p = que[0].p, deq();
		if (s == goal) break;

		if (dist[s][p] < t) continue;

		for (k = i = 0; k < nb; i++) if (s & (1<<i)) { k++, pi = ABS(p-i);
			for (m = j = 0; m < nw; j++) if (!(s & (1<<j))) { m++;
				ij = ABS(j-i);
				ns = s ^ (1<<i) ^ (1<<j);
				nt = t + pi+ij;
				if (dist[ns][j] > nt) dist[ns][j] = nt, enq(ns, nt, j);
				nt = t + ABS(p-j)+ij;
				if (dist[ns][i] > nt) dist[ns][i] = nt, enq(ns, nt, i);
			}
		}
	}
	return t;
}

int calc(char *s) { int res=0; while (*s > ' ') res = (res<<1)|(*s++ == 'B'); return res; }

int main()
{
	int n, nb, start, goal;
	char buf[20], *p;

	while (fgets(buf, 10, stdin) && *buf != '0') {
		n = atoi(buf);
		fgets(p=buf, 20, stdin); nb = 0; while (*p > ' ') if (*p++ == 'B') nb++;
		start = calc(buf);
		fgets(buf, 20, stdin), goal = calc(buf);
		if (nb > n-nb) {
			nb = n-nb;
			start = ~start & ((1<<n)-1), goal = ~goal & ((1<<n)-1);
		}
		printf("%d\n", dijkstra(n, nb, start, goal));
	}
	return 0;
}
```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	que
	.bss
	.align 32
	.type	que, @object
	.size	que, 2400000
que:
	.zero	2400000
	.globl	qsize
	.align 4
	.type	qsize, @object
	.size	qsize, 4
qsize:
	.zero	4
	.globl	qmax
	.align 4
	.type	qmax, @object
	.size	qmax, 4
qmax:
	.zero	4
	.text
	.globl	min_heapify
	.type	min_heapify, @function
min_heapify:
.LFB6:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$48, %rsp
	movl	%edi, -36(%rbp)
	movl	-36(%rbp), %eax
	addl	%eax, %eax
	movl	%eax, -16(%rbp)
	movl	-36(%rbp), %eax
	addl	%eax, %eax
	addl	$1, %eax
	movl	%eax, -12(%rbp)
	movl	qsize(%rip), %eax
	cmpl	%eax, -16(%rbp)
	jge	.L2
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	5+que(%rip), %rax
	movzbl	(%rdx,%rax), %edx
	movl	-36(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rcx
	leaq	5+que(%rip), %rax
	movzbl	(%rcx,%rax), %eax
	cmpb	%al, %dl
	jge	.L2
	movl	-16(%rbp), %eax
	movl	%eax, -20(%rbp)
	jmp	.L3
.L2:
	movl	-36(%rbp), %eax
	movl	%eax, -20(%rbp)
.L3:
	movl	qsize(%rip), %eax
	cmpl	%eax, -12(%rbp)
	jge	.L4
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	5+que(%rip), %rax
	movzbl	(%rdx,%rax), %edx
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rcx
	leaq	5+que(%rip), %rax
	movzbl	(%rcx,%rax), %eax
	cmpb	%al, %dl
	jge	.L4
	movl	-12(%rbp), %eax
	movl	%eax, -20(%rbp)
.L4:
	movl	-20(%rbp), %eax
	cmpl	-36(%rbp), %eax
	je	.L6
	movl	-36(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	que(%rip), %rax
	movq	(%rdx,%rax), %rax
	movq	%rax, -8(%rbp)
	movl	-36(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rcx
	leaq	que(%rip), %rdx
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rsi
	leaq	que(%rip), %rax
	movq	(%rsi,%rax), %rax
	movq	%rax, (%rcx,%rdx)
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rcx
	leaq	que(%rip), %rdx
	movq	-8(%rbp), %rax
	movq	%rax, (%rcx,%rdx)
	movl	-20(%rbp), %eax
	movl	%eax, %edi
	call	min_heapify
.L6:
	nop
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	min_heapify, .-min_heapify
	.globl	deq
	.type	deq, @function
deq:
.LFB7:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	qsize(%rip), %eax
	subl	$1, %eax
	movl	%eax, qsize(%rip)
	movl	qsize(%rip), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	que(%rip), %rax
	movq	(%rdx,%rax), %rax
	movq	%rax, que(%rip)
	movl	$0, %edi
	call	min_heapify
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.size	deq, .-deq
	.globl	enq
	.type	enq, @function
enq:
.LFB8:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	%edi, -20(%rbp)
	movl	%esi, -24(%rbp)
	movl	%edx, %eax
	movb	%al, -28(%rbp)
	movl	qsize(%rip), %eax
	leal	1(%rax), %edx
	movl	%edx, qsize(%rip)
	movl	%eax, -16(%rbp)
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rcx
	leaq	que(%rip), %rdx
	movl	-20(%rbp), %eax
	movl	%eax, (%rcx,%rdx)
	movl	-24(%rbp), %eax
	movl	%eax, %ecx
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	5+que(%rip), %rax
	movb	%cl, (%rdx,%rax)
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rcx
	leaq	4+que(%rip), %rdx
	movzbl	-28(%rbp), %eax
	movb	%al, (%rcx,%rdx)
	jmp	.L9
.L11:
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	que(%rip), %rax
	movq	(%rdx,%rax), %rax
	movq	%rax, -8(%rbp)
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rcx
	leaq	que(%rip), %rdx
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rsi
	leaq	que(%rip), %rax
	movq	(%rsi,%rax), %rax
	movq	%rax, (%rcx,%rdx)
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rcx
	leaq	que(%rip), %rdx
	movq	-8(%rbp), %rax
	movq	%rax, (%rcx,%rdx)
	movl	-12(%rbp), %eax
	movl	%eax, -16(%rbp)
.L9:
	cmpl	$0, -16(%rbp)
	jle	.L12
	movl	-16(%rbp), %eax
	sarl	%eax
	movl	%eax, -12(%rbp)
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	5+que(%rip), %rax
	movzbl	(%rdx,%rax), %edx
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rcx
	leaq	5+que(%rip), %rax
	movzbl	(%rcx,%rax), %eax
	cmpb	%al, %dl
	jg	.L11
.L12:
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE8:
	.size	enq, .-enq
	.globl	dist
	.bss
	.align 32
	.type	dist, @object
	.size	dist, 1048576
dist:
	.zero	1048576
	.text
	.globl	dijkstra
	.type	dijkstra, @function
dijkstra:
.LFB9:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$64, %rsp
	movl	%edi, -52(%rbp)
	movl	%esi, -56(%rbp)
	movl	%edx, -60(%rbp)
	movl	%ecx, -64(%rbp)
	movl	$1048576, %edx
	movl	$75, %esi
	leaq	dist(%rip), %rax
	movq	%rax, %rdi
	call	memset@PLT
	movl	$0, qsize(%rip)
	movl	$-1, -32(%rbp)
	movl	-52(%rbp), %eax
	subl	-56(%rbp), %eax
	movl	%eax, -24(%rbp)
	movl	$0, -28(%rbp)
	jmp	.L14
.L15:
	movl	-28(%rbp), %eax
	movslq	%eax, %rdx
	movl	-60(%rbp), %eax
	cltq
	salq	$4, %rax
	addq	%rax, %rdx
	leaq	dist(%rip), %rax
	addq	%rdx, %rax
	movb	$0, (%rax)
	movl	-28(%rbp), %eax
	movsbl	%al, %edx
	movl	-60(%rbp), %eax
	movl	$0, %esi
	movl	%eax, %edi
	call	enq
	addl	$1, -28(%rbp)
.L14:
	movl	-28(%rbp), %eax
	cmpl	-52(%rbp), %eax
	jl	.L15
	jmp	.L16
.L27:
	movl	que(%rip), %eax
	movl	%eax, -20(%rbp)
	movzbl	5+que(%rip), %eax
	movsbl	%al, %eax
	movl	%eax, -32(%rbp)
	movzbl	4+que(%rip), %eax
	movsbl	%al, %eax
	movl	%eax, -28(%rbp)
	movl	$0, %eax
	call	deq
	movl	-20(%rbp), %eax
	cmpl	-64(%rbp), %eax
	je	.L29
	movl	-28(%rbp), %eax
	movslq	%eax, %rdx
	movl	-20(%rbp), %eax
	cltq
	salq	$4, %rax
	addq	%rax, %rdx
	leaq	dist(%rip), %rax
	addq	%rdx, %rax
	movzbl	(%rax), %eax
	movsbl	%al, %eax
	cmpl	%eax, -32(%rbp)
	jle	.L19
	jmp	.L16
.L19:
	movl	$0, -48(%rbp)
	movl	-48(%rbp), %eax
	movl	%eax, -40(%rbp)
	jmp	.L20
.L26:
	movl	-48(%rbp), %eax
	movl	-20(%rbp), %edx
	movl	%eax, %ecx
	sarl	%cl, %edx
	movl	%edx, %eax
	andl	$1, %eax
	testl	%eax, %eax
	je	.L21
	addl	$1, -40(%rbp)
	movl	-28(%rbp), %eax
	subl	-48(%rbp), %eax
	movl	%eax, %edx
	negl	%edx
	cmovns	%edx, %eax
	movl	%eax, -16(%rbp)
	movl	$0, -44(%rbp)
	movl	-44(%rbp), %eax
	movl	%eax, -36(%rbp)
	jmp	.L22
.L25:
	movl	-44(%rbp), %eax
	movl	-20(%rbp), %edx
	movl	%eax, %ecx
	sarl	%cl, %edx
	movl	%edx, %eax
	andl	$1, %eax
	testl	%eax, %eax
	jne	.L23
	addl	$1, -36(%rbp)
	movl	-44(%rbp), %eax
	subl	-48(%rbp), %eax
	movl	%eax, %edx
	negl	%edx
	cmovns	%edx, %eax
	movl	%eax, -12(%rbp)
	movl	-48(%rbp), %eax
	movl	$1, %edx
	movl	%eax, %ecx
	sall	%cl, %edx
	movl	%edx, %eax
	xorl	-20(%rbp), %eax
	movl	%eax, %edx
	movl	-44(%rbp), %eax
	movl	$1, %esi
	movl	%eax, %ecx
	sall	%cl, %esi
	movl	%esi, %eax
	xorl	%edx, %eax
	movl	%eax, -8(%rbp)
	movl	-32(%rbp), %edx
	movl	-16(%rbp), %eax
	addl	%eax, %edx
	movl	-12(%rbp), %eax
	addl	%edx, %eax
	movl	%eax, -4(%rbp)
	movl	-44(%rbp), %eax
	movslq	%eax, %rdx
	movl	-8(%rbp), %eax
	cltq
	salq	$4, %rax
	addq	%rax, %rdx
	leaq	dist(%rip), %rax
	addq	%rdx, %rax
	movzbl	(%rax), %eax
	movsbl	%al, %eax
	cmpl	%eax, -4(%rbp)
	jge	.L24
	movl	-4(%rbp), %eax
	movl	%eax, %edx
	movl	-44(%rbp), %eax
	movslq	%eax, %rcx
	movl	-8(%rbp), %eax
	cltq
	salq	$4, %rax
	addq	%rax, %rcx
	leaq	dist(%rip), %rax
	addq	%rcx, %rax
	movb	%dl, (%rax)
	movl	-44(%rbp), %eax
	movsbl	%al, %edx
	movl	-4(%rbp), %ecx
	movl	-8(%rbp), %eax
	movl	%ecx, %esi
	movl	%eax, %edi
	call	enq
.L24:
	movl	-28(%rbp), %eax
	subl	-44(%rbp), %eax
	movl	%eax, %edx
	negl	%edx
	cmovs	%eax, %edx
	movl	-32(%rbp), %eax
	addl	%eax, %edx
	movl	-12(%rbp), %eax
	addl	%edx, %eax
	movl	%eax, -4(%rbp)
	movl	-48(%rbp), %eax
	movslq	%eax, %rdx
	movl	-8(%rbp), %eax
	cltq
	salq	$4, %rax
	addq	%rax, %rdx
	leaq	dist(%rip), %rax
	addq	%rdx, %rax
	movzbl	(%rax), %eax
	movsbl	%al, %eax
	cmpl	%eax, -4(%rbp)
	jge	.L23
	movl	-4(%rbp), %eax
	movl	%eax, %edx
	movl	-48(%rbp), %eax
	movslq	%eax, %rcx
	movl	-8(%rbp), %eax
	cltq
	salq	$4, %rax
	addq	%rax, %rcx
	leaq	dist(%rip), %rax
	addq	%rcx, %rax
	movb	%dl, (%rax)
	movl	-48(%rbp), %eax
	movsbl	%al, %edx
	movl	-4(%rbp), %ecx
	movl	-8(%rbp), %eax
	movl	%ecx, %esi
	movl	%eax, %edi
	call	enq
.L23:
	addl	$1, -44(%rbp)
.L22:
	movl	-36(%rbp), %eax
	cmpl	-24(%rbp), %eax
	jl	.L25
.L21:
	addl	$1, -48(%rbp)
.L20:
	movl	-40(%rbp), %eax
	cmpl	-56(%rbp), %eax
	jl	.L26
.L16:
	movl	qsize(%rip), %eax
	testl	%eax, %eax
	jne	.L27
	jmp	.L18
.L29:
	nop
.L18:
	movl	-32(%rbp), %eax
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE9:
	.size	dijkstra, .-dijkstra
	.globl	calc
	.type	calc, @function
calc:
.LFB10:
	.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	$0, -4(%rbp)
	jmp	.L31
.L32:
	movl	-4(%rbp), %eax
	leal	(%rax,%rax), %ecx
	movq	-24(%rbp), %rax
	leaq	1(%rax), %rdx
	movq	%rdx, -24(%rbp)
	movzbl	(%rax), %eax
	cmpb	$66, %al
	sete	%al
	movzbl	%al, %eax
	orl	%ecx, %eax
	movl	%eax, -4(%rbp)
.L31:
	movq	-24(%rbp), %rax
	movzbl	(%rax), %eax
	cmpb	$32, %al
	jg	.L32
	movl	-4(%rbp), %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE10:
	.size	calc, .-calc
	.section	.rodata
.LC0:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB11:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$64, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	jmp	.L35
.L40:
	leaq	-32(%rbp), %rax
	movq	%rax, %rdi
	call	atoi@PLT
	movl	%eax, -44(%rbp)
	movq	stdin(%rip), %rdx
	leaq	-32(%rbp), %rax
	movq	%rax, -40(%rbp)
	movq	-40(%rbp), %rax
	movl	$20, %esi
	movq	%rax, %rdi
	call	fgets@PLT
	movl	$0, -56(%rbp)
	jmp	.L36
.L37:
	movq	-40(%rbp), %rax
	leaq	1(%rax), %rdx
	movq	%rdx, -40(%rbp)
	movzbl	(%rax), %eax
	cmpb	$66, %al
	jne	.L36
	addl	$1, -56(%rbp)
.L36:
	movq	-40(%rbp), %rax
	movzbl	(%rax), %eax
	cmpb	$32, %al
	jg	.L37
	leaq	-32(%rbp), %rax
	movq	%rax, %rdi
	call	calc
	movl	%eax, -52(%rbp)
	movq	stdin(%rip), %rdx
	leaq	-32(%rbp), %rax
	movl	$20, %esi
	movq	%rax, %rdi
	call	fgets@PLT
	leaq	-32(%rbp), %rax
	movq	%rax, %rdi
	call	calc
	movl	%eax, -48(%rbp)
	movl	-44(%rbp), %eax
	subl	-56(%rbp), %eax
	cmpl	%eax, -56(%rbp)
	jle	.L38
	movl	-44(%rbp), %eax
	subl	-56(%rbp), %eax
	movl	%eax, -56(%rbp)
	movl	-52(%rbp), %eax
	notl	%eax
	movl	%eax, %edx
	movl	-44(%rbp), %eax
	movl	$1, %esi
	movl	%eax, %ecx
	sall	%cl, %esi
	movl	%esi, %eax
	subl	$1, %eax
	andl	%edx, %eax
	movl	%eax, -52(%rbp)
	movl	-48(%rbp), %eax
	notl	%eax
	movl	%eax, %edx
	movl	-44(%rbp), %eax
	movl	$1, %esi
	movl	%eax, %ecx
	sall	%cl, %esi
	movl	%esi, %eax
	subl	$1, %eax
	andl	%edx, %eax
	movl	%eax, -48(%rbp)
.L38:
	movl	-48(%rbp), %ecx
	movl	-52(%rbp), %edx
	movl	-56(%rbp), %esi
	movl	-44(%rbp), %eax
	movl	%eax, %edi
	call	dijkstra
	movl	%eax, %esi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L35:
	movq	stdin(%rip), %rdx
	leaq	-32(%rbp), %rax
	movl	$10, %esi
	movq	%rax, %rdi
	call	fgets@PLT
	testq	%rax, %rax
	je	.L39
	movzbl	-32(%rbp), %eax
	cmpb	$48, %al
	jne	.L40
.L39:
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L42
	call	__stack_chk_fail@PLT
.L42:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE11:
	.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	que
	.bss
	.align 32
	.type	que, @object
	.size	que, 2400000
que:
	.zero	2400000
	.globl	qsize
	.align 4
	.type	qsize, @object
	.size	qsize, 4
qsize:
	.zero	4
	.globl	qmax
	.align 4
	.type	qmax, @object
	.size	qmax, 4
qmax:
	.zero	4
	.text
	.globl	min_heapify
	.type	min_heapify, @function
min_heapify:
.LFB6:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$48, %rsp
	movl	%edi, -36(%rbp)
	movl	-36(%rbp), %eax
	addl	%eax, %eax
	movl	%eax, -16(%rbp)
	movl	-36(%rbp), %eax
	addl	%eax, %eax
	addl	$1, %eax
	movl	%eax, -12(%rbp)
	movl	qsize(%rip), %eax
	cmpl	%eax, -16(%rbp)
	jge	.L2
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	5+que(%rip), %rax
	movzbl	(%rdx,%rax), %edx
	movl	-36(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rcx
	leaq	5+que(%rip), %rax
	movzbl	(%rcx,%rax), %eax
	cmpb	%al, %dl
	jge	.L2
	movl	-16(%rbp), %eax
	movl	%eax, -20(%rbp)
	jmp	.L3
.L2:
	movl	-36(%rbp), %eax
	movl	%eax, -20(%rbp)
.L3:
	movl	qsize(%rip), %eax
	cmpl	%eax, -12(%rbp)
	jge	.L4
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	5+que(%rip), %rax
	movzbl	(%rdx,%rax), %edx
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rcx
	leaq	5+que(%rip), %rax
	movzbl	(%rcx,%rax), %eax
	cmpb	%al, %dl
	jge	.L4
	movl	-12(%rbp), %eax
	movl	%eax, -20(%rbp)
.L4:
	movl	-20(%rbp), %eax
	cmpl	-36(%rbp), %eax
	je	.L6
	movl	-36(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	que(%rip), %rax
	movq	(%rdx,%rax), %rax
	movq	%rax, -8(%rbp)
	movl	-36(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rcx
	leaq	que(%rip), %rdx
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rsi
	leaq	que(%rip), %rax
	movq	(%rsi,%rax), %rax
	movq	%rax, (%rcx,%rdx)
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rcx
	leaq	que(%rip), %rdx
	movq	-8(%rbp), %rax
	movq	%rax, (%rcx,%rdx)
	movl	-20(%rbp), %eax
	movl	%eax, %edi
	call	min_heapify
.L6:
	nop
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	min_heapify, .-min_heapify
	.globl	deq
	.type	deq, @function
deq:
.LFB7:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	qsize(%rip), %eax
	subl	$1, %eax
	movl	%eax, qsize(%rip)
	movl	qsize(%rip), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	que(%rip), %rax
	movq	(%rdx,%rax), %rax
	movq	%rax, que(%rip)
	movl	$0, %edi
	call	min_heapify
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.size	deq, .-deq
	.globl	enq
	.type	enq, @function
enq:
.LFB8:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	%edi, -20(%rbp)
	movl	%esi, -24(%rbp)
	movl	%edx, %eax
	movb	%al, -28(%rbp)
	movl	qsize(%rip), %eax
	leal	1(%rax), %edx
	movl	%edx, qsize(%rip)
	movl	%eax, -16(%rbp)
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rcx
	leaq	que(%rip), %rdx
	movl	-20(%rbp), %eax
	movl	%eax, (%rcx,%rdx)
	movl	-24(%rbp), %eax
	movl	%eax, %ecx
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	5+que(%rip), %rax
	movb	%cl, (%rdx,%rax)
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rcx
	leaq	4+que(%rip), %rdx
	movzbl	-28(%rbp), %eax
	movb	%al, (%rcx,%rdx)
	jmp	.L9
.L11:
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	que(%rip), %rax
	movq	(%rdx,%rax), %rax
	movq	%rax, -8(%rbp)
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rcx
	leaq	que(%rip), %rdx
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rsi
	leaq	que(%rip), %rax
	movq	(%rsi,%rax), %rax
	movq	%rax, (%rcx,%rdx)
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rcx
	leaq	que(%rip), %rdx
	movq	-8(%rbp), %rax
	movq	%rax, (%rcx,%rdx)
	movl	-12(%rbp), %eax
	movl	%eax, -16(%rbp)
.L9:
	cmpl	$0, -16(%rbp)
	jle	.L12
	movl	-16(%rbp), %eax
	sarl	%eax
	movl	%eax, -12(%rbp)
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	5+que(%rip), %rax
	movzbl	(%rdx,%rax), %edx
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,8), %rcx
	leaq	5+que(%rip), %rax
	movzbl	(%rcx,%rax), %eax
	cmpb	%al, %dl
	jg	.L11
.L12:
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE8:
	.size	enq, .-enq
	.globl	dist
	.bss
	.align 32
	.type	dist, @object
	.size	dist, 1048576
dist:
	.zero	1048576
	.text
	.globl	dijkstra
	.type	dijkstra, @function
dijkstra:
.LFB9:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$64, %rsp
	movl	%edi, -52(%rbp)
	movl	%esi, -56(%rbp)
	movl	%edx, -60(%rbp)
	movl	%ecx, -64(%rbp)
	movl	$1048576, %edx
	movl	$75, %esi
	leaq	dist(%rip), %rax
	movq	%rax, %rdi
	call	memset@PLT
	movl	$0, qsize(%rip)
	movl	$-1, -32(%rbp)
	movl	-52(%rbp), %eax
	subl	-56(%rbp), %eax
	movl	%eax, -24(%rbp)
	movl	$0, -28(%rbp)
	jmp	.L14
.L15:
	movl	-28(%rbp), %eax
	movslq	%eax, %rdx
	movl	-60(%rbp), %eax
	cltq
	salq	$4, %rax
	addq	%rax, %rdx
	leaq	dist(%rip), %rax
	addq	%rdx, %rax
	movb	$0, (%rax)
	movl	-28(%rbp), %eax
	movsbl	%al, %edx
	movl	-60(%rbp), %eax
	movl	$0, %esi
	movl	%eax, %edi
	call	enq
	addl	$1, -28(%rbp)
.L14:
	movl	-28(%rbp), %eax
	cmpl	-52(%rbp), %eax
	jl	.L15
	jmp	.L16
.L27:
	movl	que(%rip), %eax
	movl	%eax, -20(%rbp)
	movzbl	5+que(%rip), %eax
	movsbl	%al, %eax
	movl	%eax, -32(%rbp)
	movzbl	4+que(%rip), %eax
	movsbl	%al, %eax
	movl	%eax, -28(%rbp)
	movl	$0, %eax
	call	deq
	movl	-20(%rbp), %eax
	cmpl	-64(%rbp), %eax
	je	.L29
	movl	-28(%rbp), %eax
	movslq	%eax, %rdx
	movl	-20(%rbp), %eax
	cltq
	salq	$4, %rax
	addq	%rax, %rdx
	leaq	dist(%rip), %rax
	addq	%rdx, %rax
	movzbl	(%rax), %eax
	movsbl	%al, %eax
	cmpl	%eax, -32(%rbp)
	jle	.L19
	jmp	.L16
.L19:
	movl	$0, -48(%rbp)
	movl	-48(%rbp), %eax
	movl	%eax, -40(%rbp)
	jmp	.L20
.L26:
	movl	-48(%rbp), %eax
	movl	-20(%rbp), %edx
	movl	%eax, %ecx
	sarl	%cl, %edx
	movl	%edx, %eax
	andl	$1, %eax
	testl	%eax, %eax
	je	.L21
	addl	$1, -40(%rbp)
	movl	-28(%rbp), %eax
	subl	-48(%rbp), %eax
	movl	%eax, %edx
	negl	%edx
	cmovns	%edx, %eax
	movl	%eax, -16(%rbp)
	movl	$0, -44(%rbp)
	movl	-44(%rbp), %eax
	movl	%eax, -36(%rbp)
	jmp	.L22
.L25:
	movl	-44(%rbp), %eax
	movl	-20(%rbp), %edx
	movl	%eax, %ecx
	sarl	%cl, %edx
	movl	%edx, %eax
	andl	$1, %eax
	testl	%eax, %eax
	jne	.L23
	addl	$1, -36(%rbp)
	movl	-44(%rbp), %eax
	subl	-48(%rbp), %eax
	movl	%eax, %edx
	negl	%edx
	cmovns	%edx, %eax
	movl	%eax, -12(%rbp)
	movl	-48(%rbp), %eax
	movl	$1, %edx
	movl	%eax, %ecx
	sall	%cl, %edx
	movl	%edx, %eax
	xorl	-20(%rbp), %eax
	movl	%eax, %edx
	movl	-44(%rbp), %eax
	movl	$1, %esi
	movl	%eax, %ecx
	sall	%cl, %esi
	movl	%esi, %eax
	xorl	%edx, %eax
	movl	%eax, -8(%rbp)
	movl	-32(%rbp), %edx
	movl	-16(%rbp), %eax
	addl	%eax, %edx
	movl	-12(%rbp), %eax
	addl	%edx, %eax
	movl	%eax, -4(%rbp)
	movl	-44(%rbp), %eax
	movslq	%eax, %rdx
	movl	-8(%rbp), %eax
	cltq
	salq	$4, %rax
	addq	%rax, %rdx
	leaq	dist(%rip), %rax
	addq	%rdx, %rax
	movzbl	(%rax), %eax
	movsbl	%al, %eax
	cmpl	%eax, -4(%rbp)
	jge	.L24
	movl	-4(%rbp), %eax
	movl	%eax, %edx
	movl	-44(%rbp), %eax
	movslq	%eax, %rcx
	movl	-8(%rbp), %eax
	cltq
	salq	$4, %rax
	addq	%rax, %rcx
	leaq	dist(%rip), %rax
	addq	%rcx, %rax
	movb	%dl, (%rax)
	movl	-44(%rbp), %eax
	movsbl	%al, %edx
	movl	-4(%rbp), %ecx
	movl	-8(%rbp), %eax
	movl	%ecx, %esi
	movl	%eax, %edi
	call	enq
.L24:
	movl	-28(%rbp), %eax
	subl	-44(%rbp), %eax
	movl	%eax, %edx
	negl	%edx
	cmovs	%eax, %edx
	movl	-32(%rbp), %eax
	addl	%eax, %edx
	movl	-12(%rbp), %eax
	addl	%edx, %eax
	movl	%eax, -4(%rbp)
	movl	-48(%rbp), %eax
	movslq	%eax, %rdx
	movl	-8(%rbp), %eax
	cltq
	salq	$4, %rax
	addq	%rax, %rdx
	leaq	dist(%rip), %rax
	addq	%rdx, %rax
	movzbl	(%rax), %eax
	movsbl	%al, %eax
	cmpl	%eax, -4(%rbp)
	jge	.L23
	movl	-4(%rbp), %eax
	movl	%eax, %edx
	movl	-48(%rbp), %eax
	movslq	%eax, %rcx
	movl	-8(%rbp), %eax
	cltq
	salq	$4, %rax
	addq	%rax, %rcx
	leaq	dist(%rip), %rax
	addq	%rcx, %rax
	movb	%dl, (%rax)
	movl	-48(%rbp), %eax
	movsbl	%al, %edx
	movl	-4(%rbp), %ecx
	movl	-8(%rbp), %eax
	movl	%ecx, %esi
	movl	%eax, %edi
	call	enq
.L23:
	addl	$1, -44(%rbp)
.L22:
	movl	-36(%rbp), %eax
	cmpl	-24(%rbp), %eax
	jl	.L25
.L21:
	addl	$1, -48(%rbp)
.L20:
	movl	-40(%rbp), %eax
	cmpl	-56(%rbp), %eax
	jl	.L26
.L16:
	movl	qsize(%rip), %eax
	testl	%eax, %eax
	jne	.L27
	jmp	.L18
.L29:
	nop
.L18:
	movl	-32(%rbp), %eax
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE9:
	.size	dijkstra, .-dijkstra
	.globl	calc
	.type	calc, @function
calc:
.LFB10:
	.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	$0, -4(%rbp)
	jmp	.L31
.L32:
	movl	-4(%rbp), %eax
	leal	(%rax,%rax), %ecx
	movq	-24(%rbp), %rax
	leaq	1(%rax), %rdx
	movq	%rdx, -24(%rbp)
	movzbl	(%rax), %eax
	cmpb	$66, %al
	sete	%al
	movzbl	%al, %eax
	orl	%ecx, %eax
	movl	%eax, -4(%rbp)
.L31:
	movq	-24(%rbp), %rax
	movzbl	(%rax), %eax
	cmpb	$32, %al
	jg	.L32
	movl	-4(%rbp), %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE10:
	.size	calc, .-calc
	.section	.rodata
.LC0:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB11:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$64, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	jmp	.L35
.L40:
	leaq	-32(%rbp), %rax
	movq	%rax, %rdi
	call	atoi@PLT
	movl	%eax, -44(%rbp)
	movq	stdin(%rip), %rdx
	leaq	-32(%rbp), %rax
	movq	%rax, -40(%rbp)
	movq	-40(%rbp), %rax
	movl	$20, %esi
	movq	%rax, %rdi
	call	fgets@PLT
	movl	$0, -56(%rbp)
	jmp	.L36
.L37:
	movq	-40(%rbp), %rax
	leaq	1(%rax), %rdx
	movq	%rdx, -40(%rbp)
	movzbl	(%rax), %eax
	cmpb	$66, %al
	jne	.L36
	addl	$1, -56(%rbp)
.L36:
	movq	-40(%rbp), %rax
	movzbl	(%rax), %eax
	cmpb	$32, %al
	jg	.L37
	leaq	-32(%rbp), %rax
	movq	%rax, %rdi
	call	calc
	movl	%eax, -52(%rbp)
	movq	stdin(%rip), %rdx
	leaq	-32(%rbp), %rax
	movl	$20, %esi
	movq	%rax, %rdi
	call	fgets@PLT
	leaq	-32(%rbp), %rax
	movq	%rax, %rdi
	call	calc
	movl	%eax, -48(%rbp)
	movl	-44(%rbp), %eax
	subl	-56(%rbp), %eax
	cmpl	%eax, -56(%rbp)
	jle	.L38
	movl	-44(%rbp), %eax
	subl	-56(%rbp), %eax
	movl	%eax, -56(%rbp)
	movl	-52(%rbp), %eax
	notl	%eax
	movl	%eax, %edx
	movl	-44(%rbp), %eax
	movl	$1, %esi
	movl	%eax, %ecx
	sall	%cl, %esi
	movl	%esi, %eax
	subl	$1, %eax
	andl	%edx, %eax
	movl	%eax, -52(%rbp)
	movl	-48(%rbp), %eax
	notl	%eax
	movl	%eax, %edx
	movl	-44(%rbp), %eax
	movl	$1, %esi
	movl	%eax, %ecx
	sall	%cl, %esi
	movl	%esi, %eax
	subl	$1, %eax
	andl	%edx, %eax
	movl	%eax, -48(%rbp)
.L38:
	movl	-48(%rbp), %ecx
	movl	-52(%rbp), %edx
	movl	-56(%rbp), %esi
	movl	-44(%rbp), %eax
	movl	%eax, %edi
	call	dijkstra
	movl	%eax, %esi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L35:
	movq	stdin(%rip), %rdx
	leaq	-32(%rbp), %rax
	movl	$10, %esi
	movq	%rax, %rdi
	call	fgets@PLT
	testq	%rax, %rax
	je	.L39
	movzbl	-32(%rbp), %eax
	cmpb	$48, %al
	jne	.L40
.L39:
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L42
	call	__stack_chk_fail@PLT
.L42:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE11:
	.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:
