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<string.h>
#include<math.h>

const int INF = 1<<20;
int X,Y,dp[5][1005],ps[5][1005][2],pc[5],S[2],G[2],i,j,fp,rd,rp;char c;
int dis(int a[2],int b[2]){return abs(a[0]-b[0])+abs(a[1]-b[1]);}
int min(int a,int b){return a<b?a:b;}
int main()
{
	for(;scanf("%d%d\n",&X,&Y),X;)
	{
		memset(pc,0,sizeof(pc));
		rd=rp=INF;
		for(i=0;i<Y;i++)
			for(j=0;j<=X;j++)
			{
				c=getchar();
				if(c=='S'){S[0]=i;S[1]=j;}
				else if(c=='G'){G[0]=i;G[1]=j;}
				else if(48<c){c-='1';ps[c][pc[c]][0]=i;ps[c][pc[c]][1]=j;pc[c]++;}
			}
		for(fp=0;fp<5;fp++)
		{
			int np=(fp+1)%5,nnp;
			memset(dp,0x7f,sizeof(dp));
			for(i=0;i<pc[np];i++)dp[np][i]=dis(S,ps[np][i]);//init
			for(nnp=(np+1)%5;nnp!=fp;np=(np+1)%5,nnp=(nnp+1)%5)
				for(i=0;i<pc[np];i++)
					for(j=0;j<pc[nnp];j++)
						dp[nnp][j]=min(dp[nnp][j],dp[np][i]+dis(ps[np][i],ps[nnp][j]));
			for(np=(fp+4)%5,i=0;i<pc[np];i++)
			{
				if(rd>dp[np][i]+dis(ps[np][i],G))
				{
					rd=dp[np][i]+dis(ps[np][i],G);
					rp=fp+1;
				}
			}
		}
		if(rd==INF)puts("NA");
		else printf("%d %d\n",rp,rd);
	}
	return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	INF
	.section	.rodata
	.align 4
	.type	INF, @object
	.size	INF, 4
INF:
	.long	1048576
	.globl	X
	.bss
	.align 4
	.type	X, @object
	.size	X, 4
X:
	.zero	4
	.globl	Y
	.align 4
	.type	Y, @object
	.size	Y, 4
Y:
	.zero	4
	.globl	dp
	.align 32
	.type	dp, @object
	.size	dp, 20100
dp:
	.zero	20100
	.globl	ps
	.align 32
	.type	ps, @object
	.size	ps, 40200
ps:
	.zero	40200
	.globl	pc
	.align 16
	.type	pc, @object
	.size	pc, 20
pc:
	.zero	20
	.globl	S
	.align 8
	.type	S, @object
	.size	S, 8
S:
	.zero	8
	.globl	G
	.align 8
	.type	G, @object
	.size	G, 8
G:
	.zero	8
	.globl	i
	.align 4
	.type	i, @object
	.size	i, 4
i:
	.zero	4
	.globl	j
	.align 4
	.type	j, @object
	.size	j, 4
j:
	.zero	4
	.globl	fp
	.align 4
	.type	fp, @object
	.size	fp, 4
fp:
	.zero	4
	.globl	rd
	.align 4
	.type	rd, @object
	.size	rd, 4
rd:
	.zero	4
	.globl	rp
	.align 4
	.type	rp, @object
	.size	rp, 4
rp:
	.zero	4
	.globl	c
	.type	c, @object
	.size	c, 1
c:
	.zero	1
	.text
	.globl	dis
	.type	dis, @function
dis:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movq	%rdi, -8(%rbp)
	movq	%rsi, -16(%rbp)
	movq	-8(%rbp), %rax
	movl	(%rax), %edx
	movq	-16(%rbp), %rax
	movl	(%rax), %ecx
	movl	%edx, %eax
	subl	%ecx, %eax
	movl	%eax, %edx
	negl	%edx
	cmovns	%edx, %eax
	movl	%eax, %ecx
	movq	-8(%rbp), %rax
	addq	$4, %rax
	movl	(%rax), %eax
	movq	-16(%rbp), %rdx
	addq	$4, %rdx
	movl	(%rdx), %edx
	subl	%edx, %eax
	movl	%eax, %edx
	negl	%edx
	cmovns	%edx, %eax
	addl	%ecx, %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	dis, .-dis
	.globl	min
	.type	min, @function
min:
.LFB1:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	%edi, -4(%rbp)
	movl	%esi, -8(%rbp)
	movl	-8(%rbp), %edx
	movl	-4(%rbp), %eax
	cmpl	%eax, %edx
	cmovle	%edx, %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.size	min, .-min
	.section	.rodata
.LC0:
	.string	"NA"
.LC1:
	.string	"%d %d\n"
.LC2:
	.string	"%d%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB2:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	pushq	%rbx
	subq	$24, %rsp
	.cfi_offset 3, -24
	jmp	.L6
.L28:
	movl	$20, %edx
	movl	$0, %esi
	leaq	pc(%rip), %rax
	movq	%rax, %rdi
	call	memset@PLT
	movl	$1048576, %eax
	movl	%eax, rp(%rip)
	movl	rp(%rip), %eax
	movl	%eax, rd(%rip)
	movl	$0, i(%rip)
	jmp	.L7
.L13:
	movl	$0, j(%rip)
	jmp	.L8
.L12:
	call	getchar@PLT
	movb	%al, c(%rip)
	movzbl	c(%rip), %eax
	cmpb	$83, %al
	jne	.L9
	movl	i(%rip), %eax
	movl	%eax, S(%rip)
	movl	j(%rip), %eax
	movl	%eax, 4+S(%rip)
	jmp	.L10
.L9:
	movzbl	c(%rip), %eax
	cmpb	$71, %al
	jne	.L11
	movl	i(%rip), %eax
	movl	%eax, G(%rip)
	movl	j(%rip), %eax
	movl	%eax, 4+G(%rip)
	jmp	.L10
.L11:
	movzbl	c(%rip), %eax
	cmpb	$48, %al
	jle	.L10
	movzbl	c(%rip), %eax
	subl	$49, %eax
	movb	%al, c(%rip)
	movzbl	c(%rip), %eax
	movsbl	%al, %edx
	movzbl	c(%rip), %eax
	movsbl	%al, %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	pc(%rip), %rax
	movl	(%rcx,%rax), %ecx
	movl	i(%rip), %eax
	movslq	%ecx, %rcx
	movslq	%edx, %rdx
	imulq	$1005, %rdx, %rdx
	addq	%rcx, %rdx
	leaq	0(,%rdx,8), %rcx
	leaq	ps(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	movzbl	c(%rip), %eax
	movsbl	%al, %edx
	movzbl	c(%rip), %eax
	movsbl	%al, %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	pc(%rip), %rax
	movl	(%rcx,%rax), %ecx
	movl	j(%rip), %eax
	movslq	%ecx, %rcx
	movslq	%edx, %rdx
	imulq	$1005, %rdx, %rdx
	addq	%rcx, %rdx
	leaq	0(,%rdx,8), %rcx
	leaq	4+ps(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	movzbl	c(%rip), %eax
	movsbl	%al, %eax
	movslq	%eax, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	pc(%rip), %rdx
	movl	(%rcx,%rdx), %edx
	leal	1(%rdx), %ecx
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	pc(%rip), %rax
	movl	%ecx, (%rdx,%rax)
.L10:
	movl	j(%rip), %eax
	addl	$1, %eax
	movl	%eax, j(%rip)
.L8:
	movl	j(%rip), %edx
	movl	X(%rip), %eax
	cmpl	%eax, %edx
	jle	.L12
	movl	i(%rip), %eax
	addl	$1, %eax
	movl	%eax, i(%rip)
.L7:
	movl	i(%rip), %edx
	movl	Y(%rip), %eax
	cmpl	%eax, %edx
	jl	.L13
	movl	$0, fp(%rip)
	jmp	.L14
.L26:
	movl	fp(%rip), %eax
	addl	$1, %eax
	movslq	%eax, %rdx
	imulq	$1717986919, %rdx, %rdx
	shrq	$32, %rdx
	sarl	%edx
	movl	%eax, %ecx
	sarl	$31, %ecx
	subl	%ecx, %edx
	movl	%edx, -24(%rbp)
	movl	-24(%rbp), %ecx
	movl	%ecx, %edx
	sall	$2, %edx
	addl	%ecx, %edx
	subl	%edx, %eax
	movl	%eax, -24(%rbp)
	movl	$20100, %edx
	movl	$127, %esi
	leaq	dp(%rip), %rax
	movq	%rax, %rdi
	call	memset@PLT
	movl	$0, i(%rip)
	jmp	.L15
.L16:
	movl	i(%rip), %eax
	movslq	%eax, %rdx
	movl	-24(%rbp), %eax
	cltq
	imulq	$1005, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,8), %rdx
	leaq	ps(%rip), %rax
	addq	%rdx, %rax
	movl	i(%rip), %ebx
	movq	%rax, %rsi
	leaq	S(%rip), %rax
	movq	%rax, %rdi
	call	dis
	movslq	%ebx, %rcx
	movl	-24(%rbp), %edx
	movslq	%edx, %rdx
	imulq	$1005, %rdx, %rdx
	addq	%rcx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	dp(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	movl	i(%rip), %eax
	addl	$1, %eax
	movl	%eax, i(%rip)
.L15:
	movl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	pc(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	i(%rip), %eax
	cmpl	%eax, %edx
	jg	.L16
	movl	-24(%rbp), %eax
	addl	$1, %eax
	movslq	%eax, %rdx
	imulq	$1717986919, %rdx, %rdx
	shrq	$32, %rdx
	sarl	%edx
	movl	%eax, %ecx
	sarl	$31, %ecx
	subl	%ecx, %edx
	movl	%edx, -20(%rbp)
	movl	-20(%rbp), %ecx
	movl	%ecx, %edx
	sall	$2, %edx
	addl	%ecx, %edx
	subl	%edx, %eax
	movl	%eax, -20(%rbp)
	jmp	.L17
.L22:
	movl	$0, i(%rip)
	jmp	.L18
.L21:
	movl	$0, j(%rip)
	jmp	.L19
.L20:
	movl	i(%rip), %eax
	movslq	%eax, %rdx
	movl	-24(%rbp), %eax
	cltq
	imulq	$1005, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	dp(%rip), %rax
	movl	(%rdx,%rax), %ebx
	movl	j(%rip), %eax
	movslq	%eax, %rdx
	movl	-20(%rbp), %eax
	cltq
	imulq	$1005, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,8), %rdx
	leaq	ps(%rip), %rax
	addq	%rax, %rdx
	movl	i(%rip), %eax
	movslq	%eax, %rcx
	movl	-24(%rbp), %eax
	cltq
	imulq	$1005, %rax, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,8), %rcx
	leaq	ps(%rip), %rax
	addq	%rcx, %rax
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	dis
	leal	(%rbx,%rax), %edx
	movl	j(%rip), %eax
	movslq	%eax, %rcx
	movl	-20(%rbp), %eax
	cltq
	imulq	$1005, %rax, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rcx
	leaq	dp(%rip), %rax
	movl	(%rcx,%rax), %eax
	movl	j(%rip), %ebx
	movl	%edx, %esi
	movl	%eax, %edi
	call	min
	movslq	%ebx, %rcx
	movl	-20(%rbp), %edx
	movslq	%edx, %rdx
	imulq	$1005, %rdx, %rdx
	addq	%rcx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	dp(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	movl	j(%rip), %eax
	addl	$1, %eax
	movl	%eax, j(%rip)
.L19:
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	pc(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	j(%rip), %eax
	cmpl	%eax, %edx
	jg	.L20
	movl	i(%rip), %eax
	addl	$1, %eax
	movl	%eax, i(%rip)
.L18:
	movl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	pc(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	i(%rip), %eax
	cmpl	%eax, %edx
	jg	.L21
	movl	-24(%rbp), %eax
	addl	$1, %eax
	movslq	%eax, %rdx
	imulq	$1717986919, %rdx, %rdx
	shrq	$32, %rdx
	sarl	%edx
	movl	%eax, %ecx
	sarl	$31, %ecx
	subl	%ecx, %edx
	movl	%edx, -24(%rbp)
	movl	-24(%rbp), %ecx
	movl	%ecx, %edx
	sall	$2, %edx
	addl	%ecx, %edx
	subl	%edx, %eax
	movl	%eax, -24(%rbp)
	movl	-20(%rbp), %eax
	addl	$1, %eax
	movslq	%eax, %rdx
	imulq	$1717986919, %rdx, %rdx
	shrq	$32, %rdx
	sarl	%edx
	movl	%eax, %ecx
	sarl	$31, %ecx
	subl	%ecx, %edx
	movl	%edx, -20(%rbp)
	movl	-20(%rbp), %ecx
	movl	%ecx, %edx
	sall	$2, %edx
	addl	%ecx, %edx
	subl	%edx, %eax
	movl	%eax, -20(%rbp)
.L17:
	movl	fp(%rip), %eax
	cmpl	%eax, -20(%rbp)
	jne	.L22
	movl	fp(%rip), %eax
	addl	$4, %eax
	movslq	%eax, %rdx
	imulq	$1717986919, %rdx, %rdx
	shrq	$32, %rdx
	sarl	%edx
	movl	%eax, %ecx
	sarl	$31, %ecx
	subl	%ecx, %edx
	movl	%edx, -24(%rbp)
	movl	-24(%rbp), %ecx
	movl	%ecx, %edx
	sall	$2, %edx
	addl	%ecx, %edx
	subl	%edx, %eax
	movl	%eax, -24(%rbp)
	movl	$0, i(%rip)
	jmp	.L23
.L25:
	movl	i(%rip), %eax
	movslq	%eax, %rdx
	movl	-24(%rbp), %eax
	cltq
	imulq	$1005, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	dp(%rip), %rax
	movl	(%rdx,%rax), %ebx
	movl	i(%rip), %eax
	movslq	%eax, %rdx
	movl	-24(%rbp), %eax
	cltq
	imulq	$1005, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,8), %rdx
	leaq	ps(%rip), %rax
	addq	%rdx, %rax
	leaq	G(%rip), %rdx
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	dis
	leal	(%rbx,%rax), %edx
	movl	rd(%rip), %eax
	cmpl	%eax, %edx
	jge	.L24
	movl	i(%rip), %eax
	movslq	%eax, %rdx
	movl	-24(%rbp), %eax
	cltq
	imulq	$1005, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	dp(%rip), %rax
	movl	(%rdx,%rax), %ebx
	movl	i(%rip), %eax
	movslq	%eax, %rdx
	movl	-24(%rbp), %eax
	cltq
	imulq	$1005, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,8), %rdx
	leaq	ps(%rip), %rax
	addq	%rdx, %rax
	leaq	G(%rip), %rdx
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	dis
	addl	%ebx, %eax
	movl	%eax, rd(%rip)
	movl	fp(%rip), %eax
	addl	$1, %eax
	movl	%eax, rp(%rip)
.L24:
	movl	i(%rip), %eax
	addl	$1, %eax
	movl	%eax, i(%rip)
.L23:
	movl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	pc(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	i(%rip), %eax
	cmpl	%eax, %edx
	jg	.L25
	movl	fp(%rip), %eax
	addl	$1, %eax
	movl	%eax, fp(%rip)
.L14:
	movl	fp(%rip), %eax
	cmpl	$4, %eax
	jle	.L26
	movl	rd(%rip), %eax
	movl	$1048576, %edx
	cmpl	%edx, %eax
	jne	.L27
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	jmp	.L6
.L27:
	movl	rd(%rip), %edx
	movl	rp(%rip), %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L6:
	leaq	Y(%rip), %rax
	movq	%rax, %rdx
	leaq	X(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	X(%rip), %eax
	testl	%eax, %eax
	jne	.L28
	movl	$0, %eax
	movq	-8(%rbp), %rbx
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE2:
	.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	dis
	.type	dis, @function
dis:
.LFB35:
	.cfi_startproc
	endbr64
	movl	(%rdi), %edx
	subl	(%rsi), %edx
	movl	%edx, %eax
	negl	%eax
	cmovs	%edx, %eax
	movl	4(%rdi), %edx
	subl	4(%rsi), %edx
	movl	%edx, %ecx
	negl	%ecx
	cmovns	%ecx, %edx
	addl	%edx, %eax
	ret
	.cfi_endproc
.LFE35:
	.size	dis, .-dis
	.p2align 4
	.globl	min
	.type	min, @function
min:
.LFB36:
	.cfi_startproc
	endbr64
	cmpl	%edi, %esi
	movl	%edi, %eax
	cmovle	%esi, %eax
	ret
	.cfi_endproc
.LFE36:
	.size	min, .-min
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"NA"
.LC1:
	.string	"%d %d\n"
.LC2:
	.string	"%d%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB37:
	.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
	movl	%r9d, %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
	subq	$136, %rsp
	.cfi_def_cfa_offset 192
.L5:
	leaq	Y(%rip), %rdx
	leaq	X(%rip), %rsi
	xorl	%eax, %eax
	leaq	.LC2(%rip), %rdi
	call	__isoc99_scanf@PLT
	movl	X(%rip), %edx
	testl	%edx, %edx
	je	.L65
	movl	Y(%rip), %eax
	pxor	%xmm0, %xmm0
	movl	$0, 16+pc(%rip)
	movl	$1048576, rp(%rip)
	movl	$1048576, rd(%rip)
	movl	$0, i(%rip)
	movaps	%xmm0, pc(%rip)
	testl	%eax, %eax
	jle	.L36
	leaq	pc(%rip), %rbp
	leaq	ps(%rip), %rbx
	movq	%rbp, 96(%rsp)
.L12:
	movl	$0, j(%rip)
	testl	%edx, %edx
	jns	.L11
	jmp	.L13
.L8:
	cmpb	$71, %al
	je	.L66
	cmpb	$48, %al
	jle	.L9
	subl	$49, %eax
	movd	i(%rip), %xmm0
	movd	%edx, %xmm4
	movb	%al, c(%rip)
	movzbl	%al, %eax
	movslq	0(%rbp,%rax,4), %rsi
	imulq	$1005, %rax, %rdi
	punpckldq	%xmm4, %xmm0
	movq	%rsi, %rcx
	addl	$1, %ecx
	addq	%rdi, %rsi
	movq	%xmm0, (%rbx,%rsi,8)
	movl	%ecx, 0(%rbp,%rax,4)
.L9:
	leal	1(%rdx), %eax
	movl	X(%rip), %edx
	movl	%eax, j(%rip)
	cmpl	%edx, %eax
	jg	.L67
.L11:
	movq	stdin(%rip), %rdi
	call	getc@PLT
	movl	j(%rip), %edx
	movb	%al, c(%rip)
	cmpb	$83, %al
	jne	.L8
	movd	i(%rip), %xmm0
	movd	%edx, %xmm4
	punpckldq	%xmm4, %xmm0
	movq	%xmm0, S(%rip)
	jmp	.L9
.L66:
	movd	i(%rip), %xmm0
	movd	%edx, %xmm4
	punpckldq	%xmm4, %xmm0
	movq	%xmm0, G(%rip)
	jmp	.L9
.L67:
	movl	i(%rip), %eax
	addl	$1, %eax
	cmpl	%eax, Y(%rip)
	movl	%eax, i(%rip)
	jg	.L12
.L13:
	movl	rd(%rip), %eax
	movl	%eax, 116(%rsp)
.L6:
	movl	$1, 120(%rsp)
	leaq	dp(%rip), %r15
	movl	%r14d, %r9d
.L32:
	movl	120(%rsp), %ebx
	movl	$3435973837, %eax
	movq	%r15, %rdi
	movl	%r9d, (%rsp)
	movl	$127, %esi
	movl	$20100, %edx
	movq	%rbx, %rcx
	imulq	%rax, %rbx
	shrq	$34, %rbx
	leal	(%rbx,%rbx,4), %eax
	movl	%ecx, %ebx
	subl	%eax, %ebx
	call	memset@PLT
	movq	96(%rsp), %rax
	movslq	%ebx, %rcx
	movl	(%rsp), %r9d
	movl	(%rax,%rcx,4), %esi
	testl	%esi, %esi
	jle	.L14
	leal	-1(%rsi), %eax
	movl	S(%rip), %edi
	movl	4+S(%rip), %edx
	imulq	$1005, %rcx, %r10
	cmpl	$2, %eax
	jbe	.L37
	imulq	$8040, %rcx, %r11
	movl	%esi, %ebp
	movd	%edi, %xmm4
	xorl	%eax, %eax
	imulq	$4020, %rcx, %r12
	movd	%edx, %xmm5
	shrl	$2, %ebp
	pshufd	$0, %xmm4, %xmm4
	leaq	ps(%rip), %r8
	pshufd	$0, %xmm5, %xmm3
	salq	$4, %rbp
	addq	%r8, %r11
	addq	%r15, %r12
.L16:
	movdqu	(%r11,%rax,2), %xmm1
	movdqu	16(%r11,%rax,2), %xmm5
	movdqa	%xmm4, %xmm0
	movdqa	%xmm1, %xmm2
	shufps	$136, %xmm5, %xmm2
	psubd	%xmm2, %xmm0
	movdqa	%xmm0, %xmm2
	psrad	$31, %xmm2
	pxor	%xmm2, %xmm0
	psubd	%xmm2, %xmm0
	movdqa	%xmm1, %xmm2
	movdqa	%xmm3, %xmm1
	shufps	$221, %xmm5, %xmm2
	psubd	%xmm2, %xmm1
	movdqa	%xmm1, %xmm2
	psrad	$31, %xmm2
	pxor	%xmm2, %xmm1
	psubd	%xmm2, %xmm1
	paddd	%xmm1, %xmm0
	movups	%xmm0, (%r12,%rax)
	addq	$16, %rax
	cmpq	%rbp, %rax
	jne	.L16
	movl	%esi, %eax
	andl	$-4, %eax
	testb	$3, %sil
	je	.L14
.L15:
	movslq	%eax, %r11
	imulq	$1005, %rcx, %r13
	leaq	(%r11,%r10), %rbp
	leaq	(%r8,%rbp,8), %r12
	movl	%edi, %ebp
	subl	(%r12), %ebp
	leaq	0(%r13,%r11), %r14
	movl	%ebp, %r11d
	negl	%r11d
	cmovs	%ebp, %r11d
	movl	%edx, %ebp
	subl	4(%r12), %ebp
	movl	%ebp, %r12d
	negl	%ebp
	cmovs	%r12d, %ebp
	addl	%ebp, %r11d
	movl	%r11d, (%r15,%r14,4)
	leal	1(%rax), %r11d
	cmpl	%esi, %r11d
	jge	.L14
	movslq	%r11d, %r11
	leaq	(%r11,%r10), %rbp
	leaq	0(%r13,%r11), %r14
	leaq	(%r8,%rbp,8), %r12
	movl	%edi, %ebp
	subl	(%r12), %ebp
	movl	%ebp, %r11d
	negl	%r11d
	cmovs	%ebp, %r11d
	movl	%edx, %ebp
	subl	4(%r12), %ebp
	movl	%ebp, %r12d
	negl	%ebp
	cmovs	%r12d, %ebp
	addl	$2, %eax
	addl	%ebp, %r11d
	movl	%r11d, (%r15,%r14,4)
	cmpl	%eax, %esi
	jle	.L14
	cltq
	addq	%rax, %r10
	addq	%r13, %rax
	leaq	(%r8,%r10,8), %r8
	subl	(%r8), %edi
	movl	%edi, %r10d
	negl	%r10d
	cmovns	%r10d, %edi
	subl	4(%r8), %edx
	movl	%edx, %r8d
	negl	%r8d
	cmovns	%r8d, %edx
	addl	%edi, %edx
	movl	%edx, (%r15,%rax,4)
.L14:
	leal	1(%rbx), %eax
	movl	$3435973837, %edx
	xorl	%edi, %edi
	movq	%rax, %rbx
	movl	%eax, 108(%rsp)
	imulq	%rdx, %rax
	shrq	$34, %rax
	leal	(%rax,%rax,4), %eax
	subl	%eax, %ebx
	movl	120(%rsp), %eax
	movl	%ebx, 104(%rsp)
	subl	$1, %eax
	movl	%eax, 112(%rsp)
	cmpl	%eax, %ebx
	je	.L19
	.p2align 4,,10
	.p2align 3
.L18:
	testl	%esi, %esi
	jle	.L20
	movslq	104(%rsp), %rdx
	movq	96(%rsp), %rax
	subl	$1, %esi
	leaq	ps(%rip), %r11
	movl	(%rax,%rdx,4), %r12d
	imulq	$4020, %rcx, %rax
	imulq	$1005, %rcx, %rcx
	imulq	$1005, %rdx, %rdi
	movl	%r12d, %r10d
	andl	$-4, %r10d
	leaq	(%r15,%rax), %rbx
	leaq	1(%rcx,%rsi), %rcx
	movslq	%r10d, %r14
	movl	%r10d, 28(%rsp)
	salq	$2, %rcx
	imulq	$4020, %rdx, %rsi
	addq	%rdi, %r14
	movq	%rcx, (%rsp)
	movl	%r12d, %ecx
	imulq	$8040, %rdx, %rdx
	addq	%rdi, %rcx
	salq	$2, %rcx
	movq	%rsi, 16(%rsp)
	movq	%rcx, 8(%rsp)
	leaq	(%r15,%rsi), %rcx
	movl	%r12d, %esi
	addq	%r11, %rdx
	shrl	$2, %esi
	leal	-1(%rsi), %ebp
	leaq	(%r11,%r14,8), %rsi
	movq	%rsi, 32(%rsp)
	leal	1(%r10), %esi
	addq	$1, %rbp
	movl	%esi, 40(%rsp)
	movslq	%esi, %rsi
	salq	$4, %rbp
	addq	%rdi, %rsi
	movq	%rsi, 56(%rsp)
	leaq	(%r11,%rsi,8), %rsi
	movq	%rsi, 48(%rsp)
	leal	2(%r10), %esi
	movl	%esi, 44(%rsp)
	movslq	%esi, %rsi
	addq	%rdi, %rsi
	movq	%rsi, 72(%rsp)
	leaq	(%r11,%rsi,8), %rsi
	movq	%rsi, 64(%rsp)
	leal	-1(%r12), %esi
	movl	%esi, 24(%rsp)
	addq	%rdi, %rsi
	leaq	8(%r11), %rdi
	leaq	(%rdi,%rsi,8), %rdi
	movq	%rdi, 88(%rsp)
	.p2align 4,,10
	.p2align 3
.L26:
	testl	%r12d, %r12d
	jle	.L40
	leaq	ps(%rip), %rdi
	leaq	4(%rax), %r13
	movl	(%rdi,%rax,2), %r10d
	addq	$4, %rdi
	cmpq	%r13, 16(%rsp)
	setge	%sil
	cmpq	%rax, 8(%rsp)
	movl	(%rdi,%rax,2), %r11d
	setle	%al
	orb	%sil, %al
	je	.L41
	cmpl	$2, 24(%rsp)
	jbe	.L41
	movd	%r10d, %xmm3
	movd	(%rbx), %xmm5
	xorl	%eax, %eax
	pshufd	$0, %xmm3, %xmm4
	movd	%r11d, %xmm3
	pshufd	$0, %xmm5, %xmm5
	pshufd	$0, %xmm3, %xmm3
	.p2align 4,,10
	.p2align 3
.L23:
	movdqu	(%rdx,%rax,2), %xmm1
	movdqu	16(%rdx,%rax,2), %xmm6
	movdqa	%xmm4, %xmm0
	movdqa	%xmm1, %xmm2
	shufps	$221, %xmm6, %xmm1
	shufps	$136, %xmm6, %xmm2
	psubd	%xmm2, %xmm0
	movdqu	(%rcx,%rax), %xmm6
	movdqa	%xmm0, %xmm2
	psrad	$31, %xmm2
	pxor	%xmm2, %xmm0
	psubd	%xmm2, %xmm0
	movdqa	%xmm1, %xmm2
	movdqa	%xmm3, %xmm1
	psubd	%xmm2, %xmm1
	movdqa	%xmm1, %xmm2
	psrad	$31, %xmm2
	pxor	%xmm2, %xmm1
	psubd	%xmm2, %xmm1
	movdqa	%xmm6, %xmm2
	paddd	%xmm1, %xmm0
	paddd	%xmm5, %xmm0
	movdqa	%xmm0, %xmm1
	pcmpgtd	%xmm6, %xmm1
	pand	%xmm1, %xmm2
	pandn	%xmm0, %xmm1
	por	%xmm2, %xmm1
	movups	%xmm1, (%rcx,%rax)
	addq	$16, %rax
	cmpq	%rbp, %rax
	jne	.L23
	cmpl	28(%rsp), %r12d
	je	.L25
	movq	32(%rsp), %rdi
	movl	%r10d, %esi
	subl	(%rdi), %esi
	movl	%esi, %eax
	negl	%eax
	cmovs	%esi, %eax
	movl	%r11d, %esi
	subl	4(%rdi), %esi
	movl	%esi, %edi
	negl	%esi
	cmovs	%edi, %esi
	addl	%esi, %eax
	movl	(%r15,%r14,4), %esi
	addl	(%rbx), %eax
	cmpl	%esi, %eax
	cmovg	%esi, %eax
	movl	%eax, (%r15,%r14,4)
	cmpl	40(%rsp), %r12d
	jle	.L25
	movq	48(%rsp), %rdi
	movl	%r11d, %esi
	subl	4(%rdi), %esi
	movl	%esi, %eax
	negl	%eax
	cmovs	%esi, %eax
	movl	%r10d, %esi
	subl	(%rdi), %esi
	movl	%esi, %edi
	negl	%esi
	cmovs	%edi, %esi
	movq	56(%rsp), %rdi
	addl	%esi, %eax
	movl	(%r15,%rdi,4), %esi
	addl	(%rbx), %eax
	cmpl	%esi, %eax
	cmovg	%esi, %eax
	movl	%eax, (%r15,%rdi,4)
	cmpl	%r12d, 44(%rsp)
	jge	.L25
	movq	64(%rsp), %rdi
	subl	4(%rdi), %r11d
	movl	%r11d, %eax
	negl	%eax
	cmovs	%r11d, %eax
	subl	(%rdi), %r10d
	movq	72(%rsp), %rdi
	movl	%r10d, %esi
	negl	%esi
	cmovs	%r10d, %esi
	addl	%esi, %eax
	movl	(%r15,%rdi,4), %esi
	addl	(%rbx), %eax
	cmpl	%esi, %eax
	cmovg	%esi, %eax
	movl	%eax, (%r15,%rdi,4)
.L25:
	movl	%r12d, %r9d
.L21:
	addq	$4, %rbx
	movq	%r13, %rax
	cmpq	(%rsp), %r13
	jne	.L26
	movl	$1, %edi
.L20:
	movslq	108(%rsp), %rax
	movl	104(%rsp), %ecx
	movq	%rax, %rbx
	imulq	$1717986919, %rax, %rax
	addl	$1, %ecx
	movl	%ebx, %edx
	movl	%ecx, %esi
	sarl	$31, %edx
	sarl	$31, %esi
	sarq	$33, %rax
	subl	%edx, %eax
	leal	(%rax,%rax,4), %edx
	movl	%ebx, %eax
	subl	%edx, %eax
	movslq	%ecx, %rdx
	imulq	$1717986919, %rdx, %rdx
	sarq	$33, %rdx
	subl	%esi, %edx
	leal	(%rdx,%rdx,4), %edx
	subl	%edx, %ecx
	movl	%ecx, 104(%rsp)
	cmpl	112(%rsp), %ecx
	je	.L27
	movq	96(%rsp), %rbx
	movslq	%eax, %rcx
	addl	$1, %eax
	movl	%eax, 108(%rsp)
	movl	(%rbx,%rcx,4), %esi
	jmp	.L18
	.p2align 4,,10
	.p2align 3
.L41:
	movq	%rdx, 80(%rsp)
	movq	%rdx, %rsi
	movq	88(%rsp), %rdx
	movq	%rcx, %rdi
	.p2align 4,,10
	.p2align 3
.L22:
	movl	%r11d, %r8d
	subl	4(%rsi), %r8d
	movl	%r10d, %r9d
	movl	%r8d, %eax
	negl	%eax
	cmovs	%r8d, %eax
	subl	(%rsi), %r9d
	movl	%r9d, %r8d
	negl	%r8d
	cmovs	%r9d, %r8d
	addl	%r8d, %eax
	movl	(%rdi), %r8d
	addl	(%rbx), %eax
	cmpl	%r8d, %eax
	cmovg	%r8d, %eax
	addq	$8, %rsi
	addq	$4, %rdi
	movl	%eax, -4(%rdi)
	cmpq	%rdx, %rsi
	jne	.L22
	movq	80(%rsp), %rdx
	jmp	.L25
	.p2align 4,,10
	.p2align 3
.L40:
	xorl	%r9d, %r9d
	leaq	4(%rax), %r13
	jmp	.L21
.L27:
	testb	%dil, %dil
	je	.L19
	movl	%r9d, j(%rip)
.L19:
	movl	120(%rsp), %esi
	movl	$3435973837, %ebx
	movl	$0, i(%rip)
	leal	3(%rsi), %eax
	movq	%rax, %rdx
	imulq	%rbx, %rax
	movq	96(%rsp), %rbx
	shrq	$34, %rax
	leal	(%rax,%rax,4), %ecx
	movl	%edx, %eax
	subl	%ecx, %eax
	cltq
	movl	(%rbx,%rax,4), %ebp
	testl	%ebp, %ebp
	jle	.L29
	imulq	$4020, %rax, %rdi
	leal	-1(%rbp), %edx
	movl	G(%rip), %ebx
	xorl	%r12d, %r12d
	imulq	$8040, %rax, %rcx
	leaq	ps(%rip), %r8
	movl	4+G(%rip), %r11d
	imulq	$1005, %rax, %rax
	addq	%r15, %rdi
	addq	%r8, %rcx
	addq	%rdx, %rax
	leaq	8(%r8), %rdx
	movl	116(%rsp), %r8d
	leaq	(%rdx,%rax,8), %r10
	movl	124(%rsp), %edx
	.p2align 4,,10
	.p2align 3
.L31:
	movl	(%rcx), %r13d
	subl	%ebx, %r13d
	movl	%r13d, %eax
	negl	%eax
	cmovs	%r13d, %eax
	movl	4(%rcx), %r13d
	subl	%r11d, %r13d
	movl	%r13d, %r14d
	negl	%r14d
	cmovns	%r14d, %r13d
	addl	%r13d, %eax
	addl	(%rdi), %eax
	cmpl	%r8d, %eax
	jge	.L30
	movl	%esi, %edx
	movl	%eax, %r8d
	movl	$1, %r12d
.L30:
	addq	$8, %rcx
	addq	$4, %rdi
	cmpq	%rcx, %r10
	jne	.L31
	movl	%edx, 124(%rsp)
	movl	%ebp, i(%rip)
	testb	%r12b, %r12b
	je	.L29
	movl	%edx, rp(%rip)
	movl	%r8d, rd(%rip)
	movl	%r8d, 116(%rsp)
.L29:
	movl	120(%rsp), %eax
	movl	%eax, fp(%rip)
	addl	$1, %eax
	movl	%eax, 120(%rsp)
	cmpl	$6, %eax
	jne	.L32
	cmpl	$1048576, 116(%rsp)
	movl	%r9d, %r14d
	je	.L68
	movl	116(%rsp), %ecx
	movl	rp(%rip), %edx
	leaq	.LC1(%rip), %rsi
	xorl	%eax, %eax
	movl	$1, %edi
	call	__printf_chk@PLT
	jmp	.L5
.L37:
	xorl	%eax, %eax
	leaq	ps(%rip), %r8
	jmp	.L15
.L68:
	leaq	.LC0(%rip), %rdi
	call	puts@PLT
	jmp	.L5
.L36:
	leaq	pc(%rip), %rax
	movl	$1048576, 116(%rsp)
	movq	%rax, 96(%rsp)
	jmp	.L6
.L65:
	addq	$136, %rsp
	.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
	.cfi_endproc
.LFE37:
	.size	main, .-main
	.globl	c
	.bss
	.type	c, @object
	.size	c, 1
c:
	.zero	1
	.globl	rp
	.align 4
	.type	rp, @object
	.size	rp, 4
rp:
	.zero	4
	.globl	rd
	.align 4
	.type	rd, @object
	.size	rd, 4
rd:
	.zero	4
	.globl	fp
	.align 4
	.type	fp, @object
	.size	fp, 4
fp:
	.zero	4
	.globl	j
	.align 4
	.type	j, @object
	.size	j, 4
j:
	.zero	4
	.globl	i
	.align 4
	.type	i, @object
	.size	i, 4
i:
	.zero	4
	.globl	G
	.align 8
	.type	G, @object
	.size	G, 8
G:
	.zero	8
	.globl	S
	.align 8
	.type	S, @object
	.size	S, 8
S:
	.zero	8
	.globl	pc
	.align 16
	.type	pc, @object
	.size	pc, 20
pc:
	.zero	20
	.globl	ps
	.align 32
	.type	ps, @object
	.size	ps, 40200
ps:
	.zero	40200
	.globl	dp
	.align 32
	.type	dp, @object
	.size	dp, 20100
dp:
	.zero	20100
	.globl	Y
	.align 4
	.type	Y, @object
	.size	Y, 4
Y:
	.zero	4
	.globl	X
	.align 4
	.type	X, @object
	.size	X, 4
X:
	.zero	4
	.globl	INF
	.section	.rodata
	.align 4
	.type	INF, @object
	.size	INF, 4
INF:
	.long	1048576
	.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	dis
	.type	dis, @function
dis:
.LFB35:
	.cfi_startproc
	endbr64
	movl	(%rdi), %edx
	subl	(%rsi), %edx
	movl	%edx, %eax
	negl	%eax
	cmovs	%edx, %eax
	movl	4(%rdi), %edx
	subl	4(%rsi), %edx
	movl	%edx, %ecx
	negl	%ecx
	cmovns	%ecx, %edx
	addl	%edx, %eax
	ret
	.cfi_endproc
.LFE35:
	.size	dis, .-dis
	.p2align 4
	.globl	min
	.type	min, @function
min:
.LFB36:
	.cfi_startproc
	endbr64
	cmpl	%edi, %esi
	movl	%edi, %eax
	cmovle	%esi, %eax
	ret
	.cfi_endproc
.LFE36:
	.size	min, .-min
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"NA"
.LC1:
	.string	"%d %d\n"
.LC2:
	.string	"%d%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB37:
	.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
	movl	%r9d, %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
	subq	$136, %rsp
	.cfi_def_cfa_offset 192
.L5:
	leaq	Y(%rip), %rdx
	leaq	X(%rip), %rsi
	xorl	%eax, %eax
	leaq	.LC2(%rip), %rdi
	call	__isoc99_scanf@PLT
	movl	X(%rip), %edx
	testl	%edx, %edx
	je	.L65
	movl	Y(%rip), %eax
	pxor	%xmm0, %xmm0
	movl	$0, 16+pc(%rip)
	movl	$1048576, rp(%rip)
	movl	$1048576, rd(%rip)
	movl	$0, i(%rip)
	movaps	%xmm0, pc(%rip)
	testl	%eax, %eax
	jle	.L36
	leaq	pc(%rip), %rbp
	leaq	ps(%rip), %rbx
	movq	%rbp, 96(%rsp)
.L12:
	movl	$0, j(%rip)
	testl	%edx, %edx
	jns	.L11
	jmp	.L13
.L8:
	cmpb	$71, %al
	je	.L66
	cmpb	$48, %al
	jle	.L9
	subl	$49, %eax
	movd	i(%rip), %xmm0
	movd	%edx, %xmm4
	movb	%al, c(%rip)
	movzbl	%al, %eax
	movslq	0(%rbp,%rax,4), %rsi
	imulq	$1005, %rax, %rdi
	punpckldq	%xmm4, %xmm0
	movq	%rsi, %rcx
	addl	$1, %ecx
	addq	%rdi, %rsi
	movq	%xmm0, (%rbx,%rsi,8)
	movl	%ecx, 0(%rbp,%rax,4)
.L9:
	leal	1(%rdx), %eax
	movl	X(%rip), %edx
	movl	%eax, j(%rip)
	cmpl	%edx, %eax
	jg	.L67
.L11:
	movq	stdin(%rip), %rdi
	call	getc@PLT
	movl	j(%rip), %edx
	movb	%al, c(%rip)
	cmpb	$83, %al
	jne	.L8
	movd	i(%rip), %xmm0
	movd	%edx, %xmm4
	punpckldq	%xmm4, %xmm0
	movq	%xmm0, S(%rip)
	jmp	.L9
.L66:
	movd	i(%rip), %xmm0
	movd	%edx, %xmm4
	punpckldq	%xmm4, %xmm0
	movq	%xmm0, G(%rip)
	jmp	.L9
.L67:
	movl	i(%rip), %eax
	addl	$1, %eax
	cmpl	%eax, Y(%rip)
	movl	%eax, i(%rip)
	jg	.L12
.L13:
	movl	rd(%rip), %eax
	movl	%eax, 116(%rsp)
.L6:
	movl	$1, 120(%rsp)
	leaq	dp(%rip), %r15
	movl	%r14d, %r9d
.L32:
	movl	120(%rsp), %ebx
	movl	$3435973837, %eax
	movq	%r15, %rdi
	movl	%r9d, (%rsp)
	movl	$127, %esi
	movl	$20100, %edx
	movq	%rbx, %rcx
	imulq	%rax, %rbx
	shrq	$34, %rbx
	leal	(%rbx,%rbx,4), %eax
	movl	%ecx, %ebx
	subl	%eax, %ebx
	call	memset@PLT
	movq	96(%rsp), %rax
	movslq	%ebx, %rcx
	movl	(%rsp), %r9d
	movl	(%rax,%rcx,4), %esi
	testl	%esi, %esi
	jle	.L14
	leal	-1(%rsi), %eax
	movl	S(%rip), %edi
	movl	4+S(%rip), %edx
	imulq	$1005, %rcx, %r10
	cmpl	$2, %eax
	jbe	.L37
	imulq	$8040, %rcx, %r11
	movl	%esi, %ebp
	movd	%edi, %xmm4
	xorl	%eax, %eax
	imulq	$4020, %rcx, %r12
	movd	%edx, %xmm5
	shrl	$2, %ebp
	pshufd	$0, %xmm4, %xmm4
	leaq	ps(%rip), %r8
	pshufd	$0, %xmm5, %xmm3
	salq	$4, %rbp
	addq	%r8, %r11
	addq	%r15, %r12
.L16:
	movdqu	(%r11,%rax,2), %xmm1
	movdqu	16(%r11,%rax,2), %xmm5
	movdqa	%xmm4, %xmm0
	movdqa	%xmm1, %xmm2
	shufps	$136, %xmm5, %xmm2
	psubd	%xmm2, %xmm0
	movdqa	%xmm0, %xmm2
	psrad	$31, %xmm2
	pxor	%xmm2, %xmm0
	psubd	%xmm2, %xmm0
	movdqa	%xmm1, %xmm2
	movdqa	%xmm3, %xmm1
	shufps	$221, %xmm5, %xmm2
	psubd	%xmm2, %xmm1
	movdqa	%xmm1, %xmm2
	psrad	$31, %xmm2
	pxor	%xmm2, %xmm1
	psubd	%xmm2, %xmm1
	paddd	%xmm1, %xmm0
	movups	%xmm0, (%r12,%rax)
	addq	$16, %rax
	cmpq	%rbp, %rax
	jne	.L16
	movl	%esi, %eax
	andl	$-4, %eax
	testb	$3, %sil
	je	.L14
.L15:
	movslq	%eax, %r11
	imulq	$1005, %rcx, %r13
	leaq	(%r11,%r10), %rbp
	leaq	(%r8,%rbp,8), %r12
	movl	%edi, %ebp
	subl	(%r12), %ebp
	leaq	0(%r13,%r11), %r14
	movl	%ebp, %r11d
	negl	%r11d
	cmovs	%ebp, %r11d
	movl	%edx, %ebp
	subl	4(%r12), %ebp
	movl	%ebp, %r12d
	negl	%ebp
	cmovs	%r12d, %ebp
	addl	%ebp, %r11d
	movl	%r11d, (%r15,%r14,4)
	leal	1(%rax), %r11d
	cmpl	%esi, %r11d
	jge	.L14
	movslq	%r11d, %r11
	leaq	(%r11,%r10), %rbp
	leaq	0(%r13,%r11), %r14
	leaq	(%r8,%rbp,8), %r12
	movl	%edi, %ebp
	subl	(%r12), %ebp
	movl	%ebp, %r11d
	negl	%r11d
	cmovs	%ebp, %r11d
	movl	%edx, %ebp
	subl	4(%r12), %ebp
	movl	%ebp, %r12d
	negl	%ebp
	cmovs	%r12d, %ebp
	addl	$2, %eax
	addl	%ebp, %r11d
	movl	%r11d, (%r15,%r14,4)
	cmpl	%eax, %esi
	jle	.L14
	cltq
	addq	%rax, %r10
	addq	%r13, %rax
	leaq	(%r8,%r10,8), %r8
	subl	(%r8), %edi
	movl	%edi, %r10d
	negl	%r10d
	cmovns	%r10d, %edi
	subl	4(%r8), %edx
	movl	%edx, %r8d
	negl	%r8d
	cmovns	%r8d, %edx
	addl	%edi, %edx
	movl	%edx, (%r15,%rax,4)
.L14:
	leal	1(%rbx), %eax
	movl	$3435973837, %edx
	xorl	%edi, %edi
	movq	%rax, %rbx
	movl	%eax, 108(%rsp)
	imulq	%rdx, %rax
	shrq	$34, %rax
	leal	(%rax,%rax,4), %eax
	subl	%eax, %ebx
	movl	120(%rsp), %eax
	movl	%ebx, 104(%rsp)
	subl	$1, %eax
	movl	%eax, 112(%rsp)
	cmpl	%eax, %ebx
	je	.L19
	.p2align 4,,10
	.p2align 3
.L18:
	testl	%esi, %esi
	jle	.L20
	movslq	104(%rsp), %rdx
	movq	96(%rsp), %rax
	subl	$1, %esi
	leaq	ps(%rip), %r11
	movl	(%rax,%rdx,4), %r12d
	imulq	$4020, %rcx, %rax
	imulq	$1005, %rcx, %rcx
	imulq	$1005, %rdx, %rdi
	movl	%r12d, %r10d
	andl	$-4, %r10d
	leaq	(%r15,%rax), %rbx
	leaq	1(%rcx,%rsi), %rcx
	movslq	%r10d, %r14
	movl	%r10d, 28(%rsp)
	salq	$2, %rcx
	imulq	$4020, %rdx, %rsi
	addq	%rdi, %r14
	movq	%rcx, (%rsp)
	movl	%r12d, %ecx
	imulq	$8040, %rdx, %rdx
	addq	%rdi, %rcx
	salq	$2, %rcx
	movq	%rsi, 16(%rsp)
	movq	%rcx, 8(%rsp)
	leaq	(%r15,%rsi), %rcx
	movl	%r12d, %esi
	addq	%r11, %rdx
	shrl	$2, %esi
	leal	-1(%rsi), %ebp
	leaq	(%r11,%r14,8), %rsi
	movq	%rsi, 32(%rsp)
	leal	1(%r10), %esi
	addq	$1, %rbp
	movl	%esi, 40(%rsp)
	movslq	%esi, %rsi
	salq	$4, %rbp
	addq	%rdi, %rsi
	movq	%rsi, 56(%rsp)
	leaq	(%r11,%rsi,8), %rsi
	movq	%rsi, 48(%rsp)
	leal	2(%r10), %esi
	movl	%esi, 44(%rsp)
	movslq	%esi, %rsi
	addq	%rdi, %rsi
	movq	%rsi, 72(%rsp)
	leaq	(%r11,%rsi,8), %rsi
	movq	%rsi, 64(%rsp)
	leal	-1(%r12), %esi
	movl	%esi, 24(%rsp)
	addq	%rdi, %rsi
	leaq	8(%r11), %rdi
	leaq	(%rdi,%rsi,8), %rdi
	movq	%rdi, 88(%rsp)
	.p2align 4,,10
	.p2align 3
.L26:
	testl	%r12d, %r12d
	jle	.L40
	leaq	ps(%rip), %rdi
	leaq	4(%rax), %r13
	movl	(%rdi,%rax,2), %r10d
	addq	$4, %rdi
	cmpq	%r13, 16(%rsp)
	setge	%sil
	cmpq	%rax, 8(%rsp)
	movl	(%rdi,%rax,2), %r11d
	setle	%al
	orb	%sil, %al
	je	.L41
	cmpl	$2, 24(%rsp)
	jbe	.L41
	movd	%r10d, %xmm3
	movd	(%rbx), %xmm5
	xorl	%eax, %eax
	pshufd	$0, %xmm3, %xmm4
	movd	%r11d, %xmm3
	pshufd	$0, %xmm5, %xmm5
	pshufd	$0, %xmm3, %xmm3
	.p2align 4,,10
	.p2align 3
.L23:
	movdqu	(%rdx,%rax,2), %xmm1
	movdqu	16(%rdx,%rax,2), %xmm6
	movdqa	%xmm4, %xmm0
	movdqa	%xmm1, %xmm2
	shufps	$221, %xmm6, %xmm1
	shufps	$136, %xmm6, %xmm2
	psubd	%xmm2, %xmm0
	movdqu	(%rcx,%rax), %xmm6
	movdqa	%xmm0, %xmm2
	psrad	$31, %xmm2
	pxor	%xmm2, %xmm0
	psubd	%xmm2, %xmm0
	movdqa	%xmm1, %xmm2
	movdqa	%xmm3, %xmm1
	psubd	%xmm2, %xmm1
	movdqa	%xmm1, %xmm2
	psrad	$31, %xmm2
	pxor	%xmm2, %xmm1
	psubd	%xmm2, %xmm1
	movdqa	%xmm6, %xmm2
	paddd	%xmm1, %xmm0
	paddd	%xmm5, %xmm0
	movdqa	%xmm0, %xmm1
	pcmpgtd	%xmm6, %xmm1
	pand	%xmm1, %xmm2
	pandn	%xmm0, %xmm1
	por	%xmm2, %xmm1
	movups	%xmm1, (%rcx,%rax)
	addq	$16, %rax
	cmpq	%rbp, %rax
	jne	.L23
	cmpl	28(%rsp), %r12d
	je	.L25
	movq	32(%rsp), %rdi
	movl	%r10d, %esi
	subl	(%rdi), %esi
	movl	%esi, %eax
	negl	%eax
	cmovs	%esi, %eax
	movl	%r11d, %esi
	subl	4(%rdi), %esi
	movl	%esi, %edi
	negl	%esi
	cmovs	%edi, %esi
	addl	%esi, %eax
	movl	(%r15,%r14,4), %esi
	addl	(%rbx), %eax
	cmpl	%esi, %eax
	cmovg	%esi, %eax
	movl	%eax, (%r15,%r14,4)
	cmpl	40(%rsp), %r12d
	jle	.L25
	movq	48(%rsp), %rdi
	movl	%r11d, %esi
	subl	4(%rdi), %esi
	movl	%esi, %eax
	negl	%eax
	cmovs	%esi, %eax
	movl	%r10d, %esi
	subl	(%rdi), %esi
	movl	%esi, %edi
	negl	%esi
	cmovs	%edi, %esi
	movq	56(%rsp), %rdi
	addl	%esi, %eax
	movl	(%r15,%rdi,4), %esi
	addl	(%rbx), %eax
	cmpl	%esi, %eax
	cmovg	%esi, %eax
	movl	%eax, (%r15,%rdi,4)
	cmpl	%r12d, 44(%rsp)
	jge	.L25
	movq	64(%rsp), %rdi
	subl	4(%rdi), %r11d
	movl	%r11d, %eax
	negl	%eax
	cmovs	%r11d, %eax
	subl	(%rdi), %r10d
	movq	72(%rsp), %rdi
	movl	%r10d, %esi
	negl	%esi
	cmovs	%r10d, %esi
	addl	%esi, %eax
	movl	(%r15,%rdi,4), %esi
	addl	(%rbx), %eax
	cmpl	%esi, %eax
	cmovg	%esi, %eax
	movl	%eax, (%r15,%rdi,4)
.L25:
	movl	%r12d, %r9d
.L21:
	addq	$4, %rbx
	movq	%r13, %rax
	cmpq	(%rsp), %r13
	jne	.L26
	movl	$1, %edi
.L20:
	movslq	108(%rsp), %rax
	movl	104(%rsp), %ecx
	movq	%rax, %rbx
	imulq	$1717986919, %rax, %rax
	addl	$1, %ecx
	movl	%ebx, %edx
	movl	%ecx, %esi
	sarl	$31, %edx
	sarl	$31, %esi
	sarq	$33, %rax
	subl	%edx, %eax
	leal	(%rax,%rax,4), %edx
	movl	%ebx, %eax
	subl	%edx, %eax
	movslq	%ecx, %rdx
	imulq	$1717986919, %rdx, %rdx
	sarq	$33, %rdx
	subl	%esi, %edx
	leal	(%rdx,%rdx,4), %edx
	subl	%edx, %ecx
	movl	%ecx, 104(%rsp)
	cmpl	112(%rsp), %ecx
	je	.L27
	movq	96(%rsp), %rbx
	movslq	%eax, %rcx
	addl	$1, %eax
	movl	%eax, 108(%rsp)
	movl	(%rbx,%rcx,4), %esi
	jmp	.L18
	.p2align 4,,10
	.p2align 3
.L41:
	movq	%rdx, 80(%rsp)
	movq	%rdx, %rsi
	movq	88(%rsp), %rdx
	movq	%rcx, %rdi
	.p2align 4,,10
	.p2align 3
.L22:
	movl	%r11d, %r8d
	subl	4(%rsi), %r8d
	movl	%r10d, %r9d
	movl	%r8d, %eax
	negl	%eax
	cmovs	%r8d, %eax
	subl	(%rsi), %r9d
	movl	%r9d, %r8d
	negl	%r8d
	cmovs	%r9d, %r8d
	addl	%r8d, %eax
	movl	(%rdi), %r8d
	addl	(%rbx), %eax
	cmpl	%r8d, %eax
	cmovg	%r8d, %eax
	addq	$8, %rsi
	addq	$4, %rdi
	movl	%eax, -4(%rdi)
	cmpq	%rdx, %rsi
	jne	.L22
	movq	80(%rsp), %rdx
	jmp	.L25
	.p2align 4,,10
	.p2align 3
.L40:
	xorl	%r9d, %r9d
	leaq	4(%rax), %r13
	jmp	.L21
.L27:
	testb	%dil, %dil
	je	.L19
	movl	%r9d, j(%rip)
.L19:
	movl	120(%rsp), %esi
	movl	$3435973837, %ebx
	movl	$0, i(%rip)
	leal	3(%rsi), %eax
	movq	%rax, %rdx
	imulq	%rbx, %rax
	movq	96(%rsp), %rbx
	shrq	$34, %rax
	leal	(%rax,%rax,4), %ecx
	movl	%edx, %eax
	subl	%ecx, %eax
	cltq
	movl	(%rbx,%rax,4), %ebp
	testl	%ebp, %ebp
	jle	.L29
	imulq	$4020, %rax, %rdi
	leal	-1(%rbp), %edx
	movl	G(%rip), %ebx
	xorl	%r12d, %r12d
	imulq	$8040, %rax, %rcx
	leaq	ps(%rip), %r8
	movl	4+G(%rip), %r11d
	imulq	$1005, %rax, %rax
	addq	%r15, %rdi
	addq	%r8, %rcx
	addq	%rdx, %rax
	leaq	8(%r8), %rdx
	movl	116(%rsp), %r8d
	leaq	(%rdx,%rax,8), %r10
	movl	124(%rsp), %edx
	.p2align 4,,10
	.p2align 3
.L31:
	movl	(%rcx), %r13d
	subl	%ebx, %r13d
	movl	%r13d, %eax
	negl	%eax
	cmovs	%r13d, %eax
	movl	4(%rcx), %r13d
	subl	%r11d, %r13d
	movl	%r13d, %r14d
	negl	%r14d
	cmovns	%r14d, %r13d
	addl	%r13d, %eax
	addl	(%rdi), %eax
	cmpl	%r8d, %eax
	jge	.L30
	movl	%esi, %edx
	movl	%eax, %r8d
	movl	$1, %r12d
.L30:
	addq	$8, %rcx
	addq	$4, %rdi
	cmpq	%rcx, %r10
	jne	.L31
	movl	%edx, 124(%rsp)
	movl	%ebp, i(%rip)
	testb	%r12b, %r12b
	je	.L29
	movl	%edx, rp(%rip)
	movl	%r8d, rd(%rip)
	movl	%r8d, 116(%rsp)
.L29:
	movl	120(%rsp), %eax
	movl	%eax, fp(%rip)
	addl	$1, %eax
	movl	%eax, 120(%rsp)
	cmpl	$6, %eax
	jne	.L32
	cmpl	$1048576, 116(%rsp)
	movl	%r9d, %r14d
	je	.L68
	movl	116(%rsp), %ecx
	movl	rp(%rip), %edx
	leaq	.LC1(%rip), %rsi
	xorl	%eax, %eax
	movl	$1, %edi
	call	__printf_chk@PLT
	jmp	.L5
.L37:
	xorl	%eax, %eax
	leaq	ps(%rip), %r8
	jmp	.L15
.L68:
	leaq	.LC0(%rip), %rdi
	call	puts@PLT
	jmp	.L5
.L36:
	leaq	pc(%rip), %rax
	movl	$1048576, 116(%rsp)
	movq	%rax, 96(%rsp)
	jmp	.L6
.L65:
	addq	$136, %rsp
	.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
	.cfi_endproc
.LFE37:
	.size	main, .-main
	.globl	c
	.bss
	.type	c, @object
	.size	c, 1
c:
	.zero	1
	.globl	rp
	.align 4
	.type	rp, @object
	.size	rp, 4
rp:
	.zero	4
	.globl	rd
	.align 4
	.type	rd, @object
	.size	rd, 4
rd:
	.zero	4
	.globl	fp
	.align 4
	.type	fp, @object
	.size	fp, 4
fp:
	.zero	4
	.globl	j
	.align 4
	.type	j, @object
	.size	j, 4
j:
	.zero	4
	.globl	i
	.align 4
	.type	i, @object
	.size	i, 4
i:
	.zero	4
	.globl	G
	.align 8
	.type	G, @object
	.size	G, 8
G:
	.zero	8
	.globl	S
	.align 8
	.type	S, @object
	.size	S, 8
S:
	.zero	8
	.globl	pc
	.align 16
	.type	pc, @object
	.size	pc, 20
pc:
	.zero	20
	.globl	ps
	.align 32
	.type	ps, @object
	.size	ps, 40200
ps:
	.zero	40200
	.globl	dp
	.align 32
	.type	dp, @object
	.size	dp, 20100
dp:
	.zero	20100
	.globl	Y
	.align 4
	.type	Y, @object
	.size	Y, 4
Y:
	.zero	4
	.globl	X
	.align 4
	.type	X, @object
	.size	X, 4
X:
	.zero	4
	.globl	INF
	.section	.rodata
	.align 4
	.type	INF, @object
	.size	INF, 4
INF:
	.long	1048576
	.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<string.h>
#include<math.h>

const int INF = 1<<20;
int X,Y,dp[5][1005],ps[5][1005][2],pc[5],S[2],G[2],i,j,fp,rd,rp;char c;
int dis(int a[2],int b[2]){return abs(a[0]-b[0])+abs(a[1]-b[1]);}
int min(int a,int b){return a<b?a:b;}
int main()
{
	for(;scanf("%d%d\n",&X,&Y),X;)
	{
		memset(pc,0,sizeof(pc));
		rd=rp=INF;
		for(i=0;i<Y;i++)
			for(j=0;j<=X;j++)
			{
				c=getchar();
				if(c=='S'){S[0]=i;S[1]=j;}
				else if(c=='G'){G[0]=i;G[1]=j;}
				else if(48<c){c-='1';ps[c][pc[c]][0]=i;ps[c][pc[c]][1]=j;pc[c]++;}
			}
		for(fp=0;fp<5;fp++)
		{
			int np=(fp+1)%5,nnp;
			memset(dp,0x7f,sizeof(dp));
			for(i=0;i<pc[np];i++)dp[np][i]=dis(S,ps[np][i]);//init
			for(nnp=(np+1)%5;nnp!=fp;np=(np+1)%5,nnp=(nnp+1)%5)
				for(i=0;i<pc[np];i++)
					for(j=0;j<pc[nnp];j++)
						dp[nnp][j]=min(dp[nnp][j],dp[np][i]+dis(ps[np][i],ps[nnp][j]));
			for(np=(fp+4)%5,i=0;i<pc[np];i++)
			{
				if(rd>dp[np][i]+dis(ps[np][i],G))
				{
					rd=dp[np][i]+dis(ps[np][i],G);
					rp=fp+1;
				}
			}
		}
		if(rd==INF)puts("NA");
		else printf("%d %d\n",rp,rd);
	}
	return 0;
}
6 6
S.1..4
5..3..
..4.1.
4....5
.2.32.
5.1..G
3 2
...
S.G
0 0
 6 6
S.1..4
3..5..
..4.1.
4...5.
.2.32.
5.1..G
3 2
...
S.G
0 0
 6 6
S.1..4
4..5..
..4.1.
4....5
.2.32.
5.1..G
3 2
...
S.G
0 0
 6 6
S.1..4
3..5..
..4.1.
4...5.
.3.32.
G..1.5
3 2
...
S.G
0 0
 6 6
4.1..S
..53..
..14..
4....5
.2.32.
5.1..G
3 2
...
SG.
0 0
 6 6
S.1..4
5..3..
..41..
4....5
.2.32.
G..1.5
3 2
...
S.G
0 0
 6 6
S.1..4
3..5..
..4.1.
4...5.
.2.32.
..15.G
3 2
...
S.G
0 0
 6 6
4..1.S
4..5..
..4.1.
4....5
.2.32.
5.1..G
3 2
...
S.G
0 0
 6 6
..1S.4
3..5..
..4.1.
4....5
.2.32.
5.1..G
3 2
...
S.G
0 0
 6 6
S.1..4
3..5..
..4.1.
4....5
.2.32.
5.1G..
3 2
...
S.G
0 0

3 12
NA
 2 10
NA
 3 10
NA
 2 13
NA
 1 13
NA
 4 13
NA
 2 12
NA
 4 11
NA
 4 9
NA
 2 8
NA

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<string.h>
#include<math.h>

const int INF = 1<<20;
int X,Y,dp[5][1005],ps[5][1005][2],pc[5],S[2],G[2],i,j,fp,rd,rp;char c;
int dis(int a[2],int b[2]){return abs(a[0]-b[0])+abs(a[1]-b[1]);}
int min(int a,int b){return a<b?a:b;}
int main()
{
	for(;scanf("%d%d\n",&X,&Y),X;)
	{
		memset(pc,0,sizeof(pc));
		rd=rp=INF;
		for(i=0;i<Y;i++)
			for(j=0;j<=X;j++)
			{
				c=getchar();
				if(c=='S'){S[0]=i;S[1]=j;}
				else if(c=='G'){G[0]=i;G[1]=j;}
				else if(48<c){c-='1';ps[c][pc[c]][0]=i;ps[c][pc[c]][1]=j;pc[c]++;}
			}
		for(fp=0;fp<5;fp++)
		{
			int np=(fp+1)%5,nnp;
			memset(dp,0x7f,sizeof(dp));
			for(i=0;i<pc[np];i++)dp[np][i]=dis(S,ps[np][i]);//init
			for(nnp=(np+1)%5;nnp!=fp;np=(np+1)%5,nnp=(nnp+1)%5)
				for(i=0;i<pc[np];i++)
					for(j=0;j<pc[nnp];j++)
						dp[nnp][j]=min(dp[nnp][j],dp[np][i]+dis(ps[np][i],ps[nnp][j]));
			for(np=(fp+4)%5,i=0;i<pc[np];i++)
			{
				if(rd>dp[np][i]+dis(ps[np][i],G))
				{
					rd=dp[np][i]+dis(ps[np][i],G);
					rp=fp+1;
				}
			}
		}
		if(rd==INF)puts("NA");
		else printf("%d %d\n",rp,rd);
	}
	return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	INF
	.section	.rodata
	.align 4
	.type	INF, @object
	.size	INF, 4
INF:
	.long	1048576
	.globl	X
	.bss
	.align 4
	.type	X, @object
	.size	X, 4
X:
	.zero	4
	.globl	Y
	.align 4
	.type	Y, @object
	.size	Y, 4
Y:
	.zero	4
	.globl	dp
	.align 32
	.type	dp, @object
	.size	dp, 20100
dp:
	.zero	20100
	.globl	ps
	.align 32
	.type	ps, @object
	.size	ps, 40200
ps:
	.zero	40200
	.globl	pc
	.align 16
	.type	pc, @object
	.size	pc, 20
pc:
	.zero	20
	.globl	S
	.align 8
	.type	S, @object
	.size	S, 8
S:
	.zero	8
	.globl	G
	.align 8
	.type	G, @object
	.size	G, 8
G:
	.zero	8
	.globl	i
	.align 4
	.type	i, @object
	.size	i, 4
i:
	.zero	4
	.globl	j
	.align 4
	.type	j, @object
	.size	j, 4
j:
	.zero	4
	.globl	fp
	.align 4
	.type	fp, @object
	.size	fp, 4
fp:
	.zero	4
	.globl	rd
	.align 4
	.type	rd, @object
	.size	rd, 4
rd:
	.zero	4
	.globl	rp
	.align 4
	.type	rp, @object
	.size	rp, 4
rp:
	.zero	4
	.globl	c
	.type	c, @object
	.size	c, 1
c:
	.zero	1
	.text
	.globl	dis
	.type	dis, @function
dis:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movq	%rdi, -8(%rbp)
	movq	%rsi, -16(%rbp)
	movq	-8(%rbp), %rax
	movl	(%rax), %edx
	movq	-16(%rbp), %rax
	movl	(%rax), %ecx
	movl	%edx, %eax
	subl	%ecx, %eax
	movl	%eax, %edx
	negl	%edx
	cmovns	%edx, %eax
	movl	%eax, %ecx
	movq	-8(%rbp), %rax
	addq	$4, %rax
	movl	(%rax), %eax
	movq	-16(%rbp), %rdx
	addq	$4, %rdx
	movl	(%rdx), %edx
	subl	%edx, %eax
	movl	%eax, %edx
	negl	%edx
	cmovns	%edx, %eax
	addl	%ecx, %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	dis, .-dis
	.globl	min
	.type	min, @function
min:
.LFB1:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	%edi, -4(%rbp)
	movl	%esi, -8(%rbp)
	movl	-8(%rbp), %edx
	movl	-4(%rbp), %eax
	cmpl	%eax, %edx
	cmovle	%edx, %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.size	min, .-min
	.section	.rodata
.LC0:
	.string	"NA"
.LC1:
	.string	"%d %d\n"
.LC2:
	.string	"%d%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB2:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	pushq	%rbx
	subq	$24, %rsp
	.cfi_offset 3, -24
	jmp	.L6
.L28:
	movl	$20, %edx
	movl	$0, %esi
	leaq	pc(%rip), %rax
	movq	%rax, %rdi
	call	memset@PLT
	movl	$1048576, %eax
	movl	%eax, rp(%rip)
	movl	rp(%rip), %eax
	movl	%eax, rd(%rip)
	movl	$0, i(%rip)
	jmp	.L7
.L13:
	movl	$0, j(%rip)
	jmp	.L8
.L12:
	call	getchar@PLT
	movb	%al, c(%rip)
	movzbl	c(%rip), %eax
	cmpb	$83, %al
	jne	.L9
	movl	i(%rip), %eax
	movl	%eax, S(%rip)
	movl	j(%rip), %eax
	movl	%eax, 4+S(%rip)
	jmp	.L10
.L9:
	movzbl	c(%rip), %eax
	cmpb	$71, %al
	jne	.L11
	movl	i(%rip), %eax
	movl	%eax, G(%rip)
	movl	j(%rip), %eax
	movl	%eax, 4+G(%rip)
	jmp	.L10
.L11:
	movzbl	c(%rip), %eax
	cmpb	$48, %al
	jle	.L10
	movzbl	c(%rip), %eax
	subl	$49, %eax
	movb	%al, c(%rip)
	movzbl	c(%rip), %eax
	movsbl	%al, %edx
	movzbl	c(%rip), %eax
	movsbl	%al, %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	pc(%rip), %rax
	movl	(%rcx,%rax), %ecx
	movl	i(%rip), %eax
	movslq	%ecx, %rcx
	movslq	%edx, %rdx
	imulq	$1005, %rdx, %rdx
	addq	%rcx, %rdx
	leaq	0(,%rdx,8), %rcx
	leaq	ps(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	movzbl	c(%rip), %eax
	movsbl	%al, %edx
	movzbl	c(%rip), %eax
	movsbl	%al, %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	pc(%rip), %rax
	movl	(%rcx,%rax), %ecx
	movl	j(%rip), %eax
	movslq	%ecx, %rcx
	movslq	%edx, %rdx
	imulq	$1005, %rdx, %rdx
	addq	%rcx, %rdx
	leaq	0(,%rdx,8), %rcx
	leaq	4+ps(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	movzbl	c(%rip), %eax
	movsbl	%al, %eax
	movslq	%eax, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	pc(%rip), %rdx
	movl	(%rcx,%rdx), %edx
	leal	1(%rdx), %ecx
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	pc(%rip), %rax
	movl	%ecx, (%rdx,%rax)
.L10:
	movl	j(%rip), %eax
	addl	$1, %eax
	movl	%eax, j(%rip)
.L8:
	movl	j(%rip), %edx
	movl	X(%rip), %eax
	cmpl	%eax, %edx
	jle	.L12
	movl	i(%rip), %eax
	addl	$1, %eax
	movl	%eax, i(%rip)
.L7:
	movl	i(%rip), %edx
	movl	Y(%rip), %eax
	cmpl	%eax, %edx
	jl	.L13
	movl	$0, fp(%rip)
	jmp	.L14
.L26:
	movl	fp(%rip), %eax
	addl	$1, %eax
	movslq	%eax, %rdx
	imulq	$1717986919, %rdx, %rdx
	shrq	$32, %rdx
	sarl	%edx
	movl	%eax, %ecx
	sarl	$31, %ecx
	subl	%ecx, %edx
	movl	%edx, -24(%rbp)
	movl	-24(%rbp), %ecx
	movl	%ecx, %edx
	sall	$2, %edx
	addl	%ecx, %edx
	subl	%edx, %eax
	movl	%eax, -24(%rbp)
	movl	$20100, %edx
	movl	$127, %esi
	leaq	dp(%rip), %rax
	movq	%rax, %rdi
	call	memset@PLT
	movl	$0, i(%rip)
	jmp	.L15
.L16:
	movl	i(%rip), %eax
	movslq	%eax, %rdx
	movl	-24(%rbp), %eax
	cltq
	imulq	$1005, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,8), %rdx
	leaq	ps(%rip), %rax
	addq	%rdx, %rax
	movl	i(%rip), %ebx
	movq	%rax, %rsi
	leaq	S(%rip), %rax
	movq	%rax, %rdi
	call	dis
	movslq	%ebx, %rcx
	movl	-24(%rbp), %edx
	movslq	%edx, %rdx
	imulq	$1005, %rdx, %rdx
	addq	%rcx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	dp(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	movl	i(%rip), %eax
	addl	$1, %eax
	movl	%eax, i(%rip)
.L15:
	movl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	pc(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	i(%rip), %eax
	cmpl	%eax, %edx
	jg	.L16
	movl	-24(%rbp), %eax
	addl	$1, %eax
	movslq	%eax, %rdx
	imulq	$1717986919, %rdx, %rdx
	shrq	$32, %rdx
	sarl	%edx
	movl	%eax, %ecx
	sarl	$31, %ecx
	subl	%ecx, %edx
	movl	%edx, -20(%rbp)
	movl	-20(%rbp), %ecx
	movl	%ecx, %edx
	sall	$2, %edx
	addl	%ecx, %edx
	subl	%edx, %eax
	movl	%eax, -20(%rbp)
	jmp	.L17
.L22:
	movl	$0, i(%rip)
	jmp	.L18
.L21:
	movl	$0, j(%rip)
	jmp	.L19
.L20:
	movl	i(%rip), %eax
	movslq	%eax, %rdx
	movl	-24(%rbp), %eax
	cltq
	imulq	$1005, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	dp(%rip), %rax
	movl	(%rdx,%rax), %ebx
	movl	j(%rip), %eax
	movslq	%eax, %rdx
	movl	-20(%rbp), %eax
	cltq
	imulq	$1005, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,8), %rdx
	leaq	ps(%rip), %rax
	addq	%rax, %rdx
	movl	i(%rip), %eax
	movslq	%eax, %rcx
	movl	-24(%rbp), %eax
	cltq
	imulq	$1005, %rax, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,8), %rcx
	leaq	ps(%rip), %rax
	addq	%rcx, %rax
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	dis
	leal	(%rbx,%rax), %edx
	movl	j(%rip), %eax
	movslq	%eax, %rcx
	movl	-20(%rbp), %eax
	cltq
	imulq	$1005, %rax, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rcx
	leaq	dp(%rip), %rax
	movl	(%rcx,%rax), %eax
	movl	j(%rip), %ebx
	movl	%edx, %esi
	movl	%eax, %edi
	call	min
	movslq	%ebx, %rcx
	movl	-20(%rbp), %edx
	movslq	%edx, %rdx
	imulq	$1005, %rdx, %rdx
	addq	%rcx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	dp(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	movl	j(%rip), %eax
	addl	$1, %eax
	movl	%eax, j(%rip)
.L19:
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	pc(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	j(%rip), %eax
	cmpl	%eax, %edx
	jg	.L20
	movl	i(%rip), %eax
	addl	$1, %eax
	movl	%eax, i(%rip)
.L18:
	movl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	pc(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	i(%rip), %eax
	cmpl	%eax, %edx
	jg	.L21
	movl	-24(%rbp), %eax
	addl	$1, %eax
	movslq	%eax, %rdx
	imulq	$1717986919, %rdx, %rdx
	shrq	$32, %rdx
	sarl	%edx
	movl	%eax, %ecx
	sarl	$31, %ecx
	subl	%ecx, %edx
	movl	%edx, -24(%rbp)
	movl	-24(%rbp), %ecx
	movl	%ecx, %edx
	sall	$2, %edx
	addl	%ecx, %edx
	subl	%edx, %eax
	movl	%eax, -24(%rbp)
	movl	-20(%rbp), %eax
	addl	$1, %eax
	movslq	%eax, %rdx
	imulq	$1717986919, %rdx, %rdx
	shrq	$32, %rdx
	sarl	%edx
	movl	%eax, %ecx
	sarl	$31, %ecx
	subl	%ecx, %edx
	movl	%edx, -20(%rbp)
	movl	-20(%rbp), %ecx
	movl	%ecx, %edx
	sall	$2, %edx
	addl	%ecx, %edx
	subl	%edx, %eax
	movl	%eax, -20(%rbp)
.L17:
	movl	fp(%rip), %eax
	cmpl	%eax, -20(%rbp)
	jne	.L22
	movl	fp(%rip), %eax
	addl	$4, %eax
	movslq	%eax, %rdx
	imulq	$1717986919, %rdx, %rdx
	shrq	$32, %rdx
	sarl	%edx
	movl	%eax, %ecx
	sarl	$31, %ecx
	subl	%ecx, %edx
	movl	%edx, -24(%rbp)
	movl	-24(%rbp), %ecx
	movl	%ecx, %edx
	sall	$2, %edx
	addl	%ecx, %edx
	subl	%edx, %eax
	movl	%eax, -24(%rbp)
	movl	$0, i(%rip)
	jmp	.L23
.L25:
	movl	i(%rip), %eax
	movslq	%eax, %rdx
	movl	-24(%rbp), %eax
	cltq
	imulq	$1005, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	dp(%rip), %rax
	movl	(%rdx,%rax), %ebx
	movl	i(%rip), %eax
	movslq	%eax, %rdx
	movl	-24(%rbp), %eax
	cltq
	imulq	$1005, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,8), %rdx
	leaq	ps(%rip), %rax
	addq	%rdx, %rax
	leaq	G(%rip), %rdx
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	dis
	leal	(%rbx,%rax), %edx
	movl	rd(%rip), %eax
	cmpl	%eax, %edx
	jge	.L24
	movl	i(%rip), %eax
	movslq	%eax, %rdx
	movl	-24(%rbp), %eax
	cltq
	imulq	$1005, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	dp(%rip), %rax
	movl	(%rdx,%rax), %ebx
	movl	i(%rip), %eax
	movslq	%eax, %rdx
	movl	-24(%rbp), %eax
	cltq
	imulq	$1005, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,8), %rdx
	leaq	ps(%rip), %rax
	addq	%rdx, %rax
	leaq	G(%rip), %rdx
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	dis
	addl	%ebx, %eax
	movl	%eax, rd(%rip)
	movl	fp(%rip), %eax
	addl	$1, %eax
	movl	%eax, rp(%rip)
.L24:
	movl	i(%rip), %eax
	addl	$1, %eax
	movl	%eax, i(%rip)
.L23:
	movl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	pc(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	i(%rip), %eax
	cmpl	%eax, %edx
	jg	.L25
	movl	fp(%rip), %eax
	addl	$1, %eax
	movl	%eax, fp(%rip)
.L14:
	movl	fp(%rip), %eax
	cmpl	$4, %eax
	jle	.L26
	movl	rd(%rip), %eax
	movl	$1048576, %edx
	cmpl	%edx, %eax
	jne	.L27
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	jmp	.L6
.L27:
	movl	rd(%rip), %edx
	movl	rp(%rip), %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L6:
	leaq	Y(%rip), %rax
	movq	%rax, %rdx
	leaq	X(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	X(%rip), %eax
	testl	%eax, %eax
	jne	.L28
	movl	$0, %eax
	movq	-8(%rbp), %rbx
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE2:
	.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	INF
	.section	.rodata
	.align 4
	.type	INF, @object
	.size	INF, 4
INF:
	.long	1048576
	.globl	X
	.bss
	.align 4
	.type	X, @object
	.size	X, 4
X:
	.zero	4
	.globl	Y
	.align 4
	.type	Y, @object
	.size	Y, 4
Y:
	.zero	4
	.globl	dp
	.align 32
	.type	dp, @object
	.size	dp, 20100
dp:
	.zero	20100
	.globl	ps
	.align 32
	.type	ps, @object
	.size	ps, 40200
ps:
	.zero	40200
	.globl	pc
	.align 16
	.type	pc, @object
	.size	pc, 20
pc:
	.zero	20
	.globl	S
	.align 8
	.type	S, @object
	.size	S, 8
S:
	.zero	8
	.globl	G
	.align 8
	.type	G, @object
	.size	G, 8
G:
	.zero	8
	.globl	i
	.align 4
	.type	i, @object
	.size	i, 4
i:
	.zero	4
	.globl	j
	.align 4
	.type	j, @object
	.size	j, 4
j:
	.zero	4
	.globl	fp
	.align 4
	.type	fp, @object
	.size	fp, 4
fp:
	.zero	4
	.globl	rd
	.align 4
	.type	rd, @object
	.size	rd, 4
rd:
	.zero	4
	.globl	rp
	.align 4
	.type	rp, @object
	.size	rp, 4
rp:
	.zero	4
	.globl	c
	.type	c, @object
	.size	c, 1
c:
	.zero	1
	.text
	.globl	dis
	.type	dis, @function
dis:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movq	%rdi, -8(%rbp)
	movq	%rsi, -16(%rbp)
	movq	-8(%rbp), %rax
	movl	(%rax), %edx
	movq	-16(%rbp), %rax
	movl	(%rax), %ecx
	movl	%edx, %eax
	subl	%ecx, %eax
	movl	%eax, %edx
	negl	%edx
	cmovns	%edx, %eax
	movl	%eax, %ecx
	movq	-8(%rbp), %rax
	addq	$4, %rax
	movl	(%rax), %eax
	movq	-16(%rbp), %rdx
	addq	$4, %rdx
	movl	(%rdx), %edx
	subl	%edx, %eax
	movl	%eax, %edx
	negl	%edx
	cmovns	%edx, %eax
	addl	%ecx, %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	dis, .-dis
	.globl	min
	.type	min, @function
min:
.LFB1:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	%edi, -4(%rbp)
	movl	%esi, -8(%rbp)
	movl	-8(%rbp), %edx
	movl	-4(%rbp), %eax
	cmpl	%eax, %edx
	cmovle	%edx, %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.size	min, .-min
	.section	.rodata
.LC0:
	.string	"NA"
.LC1:
	.string	"%d %d\n"
.LC2:
	.string	"%d%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB2:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	pushq	%rbx
	subq	$24, %rsp
	.cfi_offset 3, -24
	jmp	.L6
.L28:
	movl	$20, %edx
	movl	$0, %esi
	leaq	pc(%rip), %rax
	movq	%rax, %rdi
	call	memset@PLT
	movl	$1048576, %eax
	movl	%eax, rp(%rip)
	movl	rp(%rip), %eax
	movl	%eax, rd(%rip)
	movl	$0, i(%rip)
	jmp	.L7
.L13:
	movl	$0, j(%rip)
	jmp	.L8
.L12:
	call	getchar@PLT
	movb	%al, c(%rip)
	movzbl	c(%rip), %eax
	cmpb	$83, %al
	jne	.L9
	movl	i(%rip), %eax
	movl	%eax, S(%rip)
	movl	j(%rip), %eax
	movl	%eax, 4+S(%rip)
	jmp	.L10
.L9:
	movzbl	c(%rip), %eax
	cmpb	$71, %al
	jne	.L11
	movl	i(%rip), %eax
	movl	%eax, G(%rip)
	movl	j(%rip), %eax
	movl	%eax, 4+G(%rip)
	jmp	.L10
.L11:
	movzbl	c(%rip), %eax
	cmpb	$48, %al
	jle	.L10
	movzbl	c(%rip), %eax
	subl	$49, %eax
	movb	%al, c(%rip)
	movzbl	c(%rip), %eax
	movsbl	%al, %edx
	movzbl	c(%rip), %eax
	movsbl	%al, %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	pc(%rip), %rax
	movl	(%rcx,%rax), %ecx
	movl	i(%rip), %eax
	movslq	%ecx, %rcx
	movslq	%edx, %rdx
	imulq	$1005, %rdx, %rdx
	addq	%rcx, %rdx
	leaq	0(,%rdx,8), %rcx
	leaq	ps(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	movzbl	c(%rip), %eax
	movsbl	%al, %edx
	movzbl	c(%rip), %eax
	movsbl	%al, %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	pc(%rip), %rax
	movl	(%rcx,%rax), %ecx
	movl	j(%rip), %eax
	movslq	%ecx, %rcx
	movslq	%edx, %rdx
	imulq	$1005, %rdx, %rdx
	addq	%rcx, %rdx
	leaq	0(,%rdx,8), %rcx
	leaq	4+ps(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	movzbl	c(%rip), %eax
	movsbl	%al, %eax
	movslq	%eax, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	pc(%rip), %rdx
	movl	(%rcx,%rdx), %edx
	leal	1(%rdx), %ecx
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	pc(%rip), %rax
	movl	%ecx, (%rdx,%rax)
.L10:
	movl	j(%rip), %eax
	addl	$1, %eax
	movl	%eax, j(%rip)
.L8:
	movl	j(%rip), %edx
	movl	X(%rip), %eax
	cmpl	%eax, %edx
	jle	.L12
	movl	i(%rip), %eax
	addl	$1, %eax
	movl	%eax, i(%rip)
.L7:
	movl	i(%rip), %edx
	movl	Y(%rip), %eax
	cmpl	%eax, %edx
	jl	.L13
	movl	$0, fp(%rip)
	jmp	.L14
.L26:
	movl	fp(%rip), %eax
	addl	$1, %eax
	movslq	%eax, %rdx
	imulq	$1717986919, %rdx, %rdx
	shrq	$32, %rdx
	sarl	%edx
	movl	%eax, %ecx
	sarl	$31, %ecx
	subl	%ecx, %edx
	movl	%edx, -24(%rbp)
	movl	-24(%rbp), %ecx
	movl	%ecx, %edx
	sall	$2, %edx
	addl	%ecx, %edx
	subl	%edx, %eax
	movl	%eax, -24(%rbp)
	movl	$20100, %edx
	movl	$127, %esi
	leaq	dp(%rip), %rax
	movq	%rax, %rdi
	call	memset@PLT
	movl	$0, i(%rip)
	jmp	.L15
.L16:
	movl	i(%rip), %eax
	movslq	%eax, %rdx
	movl	-24(%rbp), %eax
	cltq
	imulq	$1005, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,8), %rdx
	leaq	ps(%rip), %rax
	addq	%rdx, %rax
	movl	i(%rip), %ebx
	movq	%rax, %rsi
	leaq	S(%rip), %rax
	movq	%rax, %rdi
	call	dis
	movslq	%ebx, %rcx
	movl	-24(%rbp), %edx
	movslq	%edx, %rdx
	imulq	$1005, %rdx, %rdx
	addq	%rcx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	dp(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	movl	i(%rip), %eax
	addl	$1, %eax
	movl	%eax, i(%rip)
.L15:
	movl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	pc(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	i(%rip), %eax
	cmpl	%eax, %edx
	jg	.L16
	movl	-24(%rbp), %eax
	addl	$1, %eax
	movslq	%eax, %rdx
	imulq	$1717986919, %rdx, %rdx
	shrq	$32, %rdx
	sarl	%edx
	movl	%eax, %ecx
	sarl	$31, %ecx
	subl	%ecx, %edx
	movl	%edx, -20(%rbp)
	movl	-20(%rbp), %ecx
	movl	%ecx, %edx
	sall	$2, %edx
	addl	%ecx, %edx
	subl	%edx, %eax
	movl	%eax, -20(%rbp)
	jmp	.L17
.L22:
	movl	$0, i(%rip)
	jmp	.L18
.L21:
	movl	$0, j(%rip)
	jmp	.L19
.L20:
	movl	i(%rip), %eax
	movslq	%eax, %rdx
	movl	-24(%rbp), %eax
	cltq
	imulq	$1005, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	dp(%rip), %rax
	movl	(%rdx,%rax), %ebx
	movl	j(%rip), %eax
	movslq	%eax, %rdx
	movl	-20(%rbp), %eax
	cltq
	imulq	$1005, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,8), %rdx
	leaq	ps(%rip), %rax
	addq	%rax, %rdx
	movl	i(%rip), %eax
	movslq	%eax, %rcx
	movl	-24(%rbp), %eax
	cltq
	imulq	$1005, %rax, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,8), %rcx
	leaq	ps(%rip), %rax
	addq	%rcx, %rax
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	dis
	leal	(%rbx,%rax), %edx
	movl	j(%rip), %eax
	movslq	%eax, %rcx
	movl	-20(%rbp), %eax
	cltq
	imulq	$1005, %rax, %rax
	addq	%rcx, %rax
	leaq	0(,%rax,4), %rcx
	leaq	dp(%rip), %rax
	movl	(%rcx,%rax), %eax
	movl	j(%rip), %ebx
	movl	%edx, %esi
	movl	%eax, %edi
	call	min
	movslq	%ebx, %rcx
	movl	-20(%rbp), %edx
	movslq	%edx, %rdx
	imulq	$1005, %rdx, %rdx
	addq	%rcx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	dp(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	movl	j(%rip), %eax
	addl	$1, %eax
	movl	%eax, j(%rip)
.L19:
	movl	-20(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	pc(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	j(%rip), %eax
	cmpl	%eax, %edx
	jg	.L20
	movl	i(%rip), %eax
	addl	$1, %eax
	movl	%eax, i(%rip)
.L18:
	movl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	pc(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	i(%rip), %eax
	cmpl	%eax, %edx
	jg	.L21
	movl	-24(%rbp), %eax
	addl	$1, %eax
	movslq	%eax, %rdx
	imulq	$1717986919, %rdx, %rdx
	shrq	$32, %rdx
	sarl	%edx
	movl	%eax, %ecx
	sarl	$31, %ecx
	subl	%ecx, %edx
	movl	%edx, -24(%rbp)
	movl	-24(%rbp), %ecx
	movl	%ecx, %edx
	sall	$2, %edx
	addl	%ecx, %edx
	subl	%edx, %eax
	movl	%eax, -24(%rbp)
	movl	-20(%rbp), %eax
	addl	$1, %eax
	movslq	%eax, %rdx
	imulq	$1717986919, %rdx, %rdx
	shrq	$32, %rdx
	sarl	%edx
	movl	%eax, %ecx
	sarl	$31, %ecx
	subl	%ecx, %edx
	movl	%edx, -20(%rbp)
	movl	-20(%rbp), %ecx
	movl	%ecx, %edx
	sall	$2, %edx
	addl	%ecx, %edx
	subl	%edx, %eax
	movl	%eax, -20(%rbp)
.L17:
	movl	fp(%rip), %eax
	cmpl	%eax, -20(%rbp)
	jne	.L22
	movl	fp(%rip), %eax
	addl	$4, %eax
	movslq	%eax, %rdx
	imulq	$1717986919, %rdx, %rdx
	shrq	$32, %rdx
	sarl	%edx
	movl	%eax, %ecx
	sarl	$31, %ecx
	subl	%ecx, %edx
	movl	%edx, -24(%rbp)
	movl	-24(%rbp), %ecx
	movl	%ecx, %edx
	sall	$2, %edx
	addl	%ecx, %edx
	subl	%edx, %eax
	movl	%eax, -24(%rbp)
	movl	$0, i(%rip)
	jmp	.L23
.L25:
	movl	i(%rip), %eax
	movslq	%eax, %rdx
	movl	-24(%rbp), %eax
	cltq
	imulq	$1005, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	dp(%rip), %rax
	movl	(%rdx,%rax), %ebx
	movl	i(%rip), %eax
	movslq	%eax, %rdx
	movl	-24(%rbp), %eax
	cltq
	imulq	$1005, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,8), %rdx
	leaq	ps(%rip), %rax
	addq	%rdx, %rax
	leaq	G(%rip), %rdx
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	dis
	leal	(%rbx,%rax), %edx
	movl	rd(%rip), %eax
	cmpl	%eax, %edx
	jge	.L24
	movl	i(%rip), %eax
	movslq	%eax, %rdx
	movl	-24(%rbp), %eax
	cltq
	imulq	$1005, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	dp(%rip), %rax
	movl	(%rdx,%rax), %ebx
	movl	i(%rip), %eax
	movslq	%eax, %rdx
	movl	-24(%rbp), %eax
	cltq
	imulq	$1005, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,8), %rdx
	leaq	ps(%rip), %rax
	addq	%rdx, %rax
	leaq	G(%rip), %rdx
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	dis
	addl	%ebx, %eax
	movl	%eax, rd(%rip)
	movl	fp(%rip), %eax
	addl	$1, %eax
	movl	%eax, rp(%rip)
.L24:
	movl	i(%rip), %eax
	addl	$1, %eax
	movl	%eax, i(%rip)
.L23:
	movl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	pc(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	i(%rip), %eax
	cmpl	%eax, %edx
	jg	.L25
	movl	fp(%rip), %eax
	addl	$1, %eax
	movl	%eax, fp(%rip)
.L14:
	movl	fp(%rip), %eax
	cmpl	$4, %eax
	jle	.L26
	movl	rd(%rip), %eax
	movl	$1048576, %edx
	cmpl	%edx, %eax
	jne	.L27
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	jmp	.L6
.L27:
	movl	rd(%rip), %edx
	movl	rp(%rip), %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L6:
	leaq	Y(%rip), %rax
	movq	%rax, %rdx
	leaq	X(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	X(%rip), %eax
	testl	%eax, %eax
	jne	.L28
	movl	$0, %eax
	movq	-8(%rbp), %rbx
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE2:
	.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:
