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

```c
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int N,M,H,K,S[1001],Y[100001][2],W[100001][2],P[1001],Q[1001],i,j,R,t,r,x,y;
void s(int *a,int *b){*a^=*b^=*a^=*b;}
int c(const void *a, const void *b){return ((int*)a)[1]-((int*)b)[1];}
int main()
{
	for(;scanf("%d%d%d%d",&N,&M,&H,&K),N;)
	{
		for(i=0;i<N;S[i],P[i]=i++)scanf("%d",&S[i]);
		for(i=0;i<M;Y[i][0]--,i++)scanf("%d%d",&Y[i][0],&Y[i][1]);
		qsort(Y,M,sizeof(int[2]),c);
		for(i=0;i<M;i++)
		{
			W[i][0]=P[Y[i][0]];
			W[i][1]=P[Y[i][0]+1];
			s(&P[Y[i][0]],&P[Y[i][0]+1]);
		}
		for(i=0;i<N;i++)Q[P[i]]=i;
		for(i=R=0;i<K;i++)R+=S[Q[i]];
		for(i=0,r=t=R;i<M;i++,t=r)
		{
			x=W[i][0],y=W[i][1];
			if(x<K&&y>=K)t=t-S[Q[x]]+S[Q[y]];
			if(y<K&&x>=K)t=t-S[Q[y]]+S[Q[x]];
			R=R>t?t:R;
		}
		printf("%d\n",R);
	}
	return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	N
	.bss
	.align 4
	.type	N, @object
	.size	N, 4
N:
	.zero	4
	.globl	M
	.align 4
	.type	M, @object
	.size	M, 4
M:
	.zero	4
	.globl	H
	.align 4
	.type	H, @object
	.size	H, 4
H:
	.zero	4
	.globl	K
	.align 4
	.type	K, @object
	.size	K, 4
K:
	.zero	4
	.globl	S
	.align 32
	.type	S, @object
	.size	S, 4004
S:
	.zero	4004
	.globl	Y
	.align 32
	.type	Y, @object
	.size	Y, 800008
Y:
	.zero	800008
	.globl	W
	.align 32
	.type	W, @object
	.size	W, 800008
W:
	.zero	800008
	.globl	P
	.align 32
	.type	P, @object
	.size	P, 4004
P:
	.zero	4004
	.globl	Q
	.align 32
	.type	Q, @object
	.size	Q, 4004
Q:
	.zero	4004
	.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	R
	.align 4
	.type	R, @object
	.size	R, 4
R:
	.zero	4
	.globl	t
	.align 4
	.type	t, @object
	.size	t, 4
t:
	.zero	4
	.globl	r
	.align 4
	.type	r, @object
	.size	r, 4
r:
	.zero	4
	.globl	x
	.align 4
	.type	x, @object
	.size	x, 4
x:
	.zero	4
	.globl	y
	.align 4
	.type	y, @object
	.size	y, 4
y:
	.zero	4
	.text
	.globl	s
	.type	s, @function
s:
.LFB6:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movq	%rdi, -8(%rbp)
	movq	%rsi, -16(%rbp)
	movq	-8(%rbp), %rax
	movl	(%rax), %edx
	movq	-16(%rbp), %rax
	movl	(%rax), %eax
	xorl	%eax, %edx
	movq	-8(%rbp), %rax
	movl	%edx, (%rax)
	movq	-8(%rbp), %rax
	movl	(%rax), %edx
	movq	-16(%rbp), %rax
	movl	(%rax), %eax
	xorl	%eax, %edx
	movq	-16(%rbp), %rax
	movl	%edx, (%rax)
	movq	-16(%rbp), %rax
	movl	(%rax), %edx
	movq	-8(%rbp), %rax
	movl	(%rax), %eax
	xorl	%eax, %edx
	movq	-8(%rbp), %rax
	movl	%edx, (%rax)
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	s, .-s
	.globl	c
	.type	c, @function
c:
.LFB7:
	.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
	addq	$4, %rax
	movl	(%rax), %eax
	movq	-16(%rbp), %rdx
	addq	$4, %rdx
	movl	(%rdx), %edx
	subl	%edx, %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.size	c, .-c
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%d%d"
.LC2:
	.string	"%d\n"
.LC3:
	.string	"%d%d%d%d"
	.text
	.globl	main
	.type	main, @function
main:
.LFB8:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	jmp	.L5
.L20:
	movl	$0, i(%rip)
	jmp	.L6
.L7:
	movl	i(%rip), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	S(%rip), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	i(%rip), %eax
	leal	1(%rax), %edx
	movl	%edx, i(%rip)
	movl	i(%rip), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	P(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
.L6:
	movl	i(%rip), %edx
	movl	N(%rip), %eax
	cmpl	%eax, %edx
	jl	.L7
	movl	$0, i(%rip)
	jmp	.L8
.L9:
	movl	i(%rip), %eax
	cltq
	salq	$3, %rax
	leaq	4(%rax), %rdx
	leaq	Y(%rip), %rax
	addq	%rax, %rdx
	movl	i(%rip), %eax
	cltq
	leaq	0(,%rax,8), %rcx
	leaq	Y(%rip), %rax
	addq	%rcx, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	i(%rip), %eax
	movslq	%eax, %rdx
	leaq	0(,%rdx,8), %rcx
	leaq	Y(%rip), %rdx
	movl	(%rcx,%rdx), %edx
	leal	-1(%rdx), %ecx
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	Y(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	movl	i(%rip), %eax
	addl	$1, %eax
	movl	%eax, i(%rip)
.L8:
	movl	i(%rip), %edx
	movl	M(%rip), %eax
	cmpl	%eax, %edx
	jl	.L9
	movl	M(%rip), %eax
	cltq
	leaq	c(%rip), %rdx
	movq	%rdx, %rcx
	movl	$8, %edx
	movq	%rax, %rsi
	leaq	Y(%rip), %rax
	movq	%rax, %rdi
	call	qsort@PLT
	movl	$0, i(%rip)
	jmp	.L10
.L11:
	movl	i(%rip), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	Y(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	i(%rip), %edx
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	P(%rip), %rax
	movl	(%rcx,%rax), %eax
	movslq	%edx, %rdx
	leaq	0(,%rdx,8), %rcx
	leaq	W(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	movl	i(%rip), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	Y(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	$1, %eax
	movl	i(%rip), %edx
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	P(%rip), %rax
	movl	(%rcx,%rax), %eax
	movslq	%edx, %rdx
	leaq	0(,%rdx,8), %rcx
	leaq	4+W(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	movl	i(%rip), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	Y(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	$1, %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	P(%rip), %rax
	addq	%rax, %rdx
	movl	i(%rip), %eax
	cltq
	leaq	0(,%rax,8), %rcx
	leaq	Y(%rip), %rax
	movl	(%rcx,%rax), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	P(%rip), %rax
	addq	%rcx, %rax
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	s
	movl	i(%rip), %eax
	addl	$1, %eax
	movl	%eax, i(%rip)
.L10:
	movl	i(%rip), %edx
	movl	M(%rip), %eax
	cmpl	%eax, %edx
	jl	.L11
	movl	$0, i(%rip)
	jmp	.L12
.L13:
	movl	i(%rip), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	P(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	i(%rip), %eax
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	Q(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	movl	i(%rip), %eax
	addl	$1, %eax
	movl	%eax, i(%rip)
.L12:
	movl	i(%rip), %edx
	movl	N(%rip), %eax
	cmpl	%eax, %edx
	jl	.L13
	movl	$0, R(%rip)
	movl	R(%rip), %eax
	movl	%eax, i(%rip)
	jmp	.L14
.L15:
	movl	i(%rip), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	Q(%rip), %rax
	movl	(%rdx,%rax), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	S(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	R(%rip), %eax
	addl	%edx, %eax
	movl	%eax, R(%rip)
	movl	i(%rip), %eax
	addl	$1, %eax
	movl	%eax, i(%rip)
.L14:
	movl	i(%rip), %edx
	movl	K(%rip), %eax
	cmpl	%eax, %edx
	jl	.L15
	movl	$0, i(%rip)
	movl	R(%rip), %eax
	movl	%eax, t(%rip)
	movl	t(%rip), %eax
	movl	%eax, r(%rip)
	jmp	.L16
.L19:
	movl	i(%rip), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	W(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, x(%rip)
	movl	i(%rip), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	4+W(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, y(%rip)
	movl	x(%rip), %edx
	movl	K(%rip), %eax
	cmpl	%eax, %edx
	jge	.L17
	movl	y(%rip), %edx
	movl	K(%rip), %eax
	cmpl	%eax, %edx
	jl	.L17
	movl	t(%rip), %eax
	movl	x(%rip), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	Q(%rip), %rdx
	movl	(%rcx,%rdx), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	S(%rip), %rdx
	movl	(%rcx,%rdx), %edx
	subl	%edx, %eax
	movl	%eax, %ecx
	movl	y(%rip), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	Q(%rip), %rax
	movl	(%rdx,%rax), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	S(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	%ecx, %eax
	movl	%eax, t(%rip)
.L17:
	movl	y(%rip), %edx
	movl	K(%rip), %eax
	cmpl	%eax, %edx
	jge	.L18
	movl	x(%rip), %edx
	movl	K(%rip), %eax
	cmpl	%eax, %edx
	jl	.L18
	movl	t(%rip), %eax
	movl	y(%rip), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	Q(%rip), %rdx
	movl	(%rcx,%rdx), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	S(%rip), %rdx
	movl	(%rcx,%rdx), %edx
	subl	%edx, %eax
	movl	%eax, %ecx
	movl	x(%rip), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	Q(%rip), %rax
	movl	(%rdx,%rax), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	S(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	%ecx, %eax
	movl	%eax, t(%rip)
.L18:
	movl	R(%rip), %edx
	movl	t(%rip), %eax
	cmpl	%eax, %edx
	cmovle	%edx, %eax
	movl	%eax, R(%rip)
	movl	i(%rip), %eax
	addl	$1, %eax
	movl	%eax, i(%rip)
	movl	r(%rip), %eax
	movl	%eax, t(%rip)
.L16:
	movl	i(%rip), %edx
	movl	M(%rip), %eax
	cmpl	%eax, %edx
	jl	.L19
	movl	R(%rip), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L5:
	leaq	K(%rip), %r8
	leaq	H(%rip), %rax
	movq	%rax, %rcx
	leaq	M(%rip), %rax
	movq	%rax, %rdx
	leaq	N(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	N(%rip), %eax
	testl	%eax, %eax
	jne	.L20
	movl	$0, %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE8:
	.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	c
	.type	c, @function
c:
.LFB52:
	.cfi_startproc
	endbr64
	movl	4(%rdi), %eax
	subl	4(%rsi), %eax
	ret
	.cfi_endproc
.LFE52:
	.size	c, .-c
	.p2align 4
	.globl	s
	.type	s, @function
s:
.LFB51:
	.cfi_startproc
	endbr64
	movl	(%rdi), %eax
	xorl	(%rsi), %eax
	movl	%eax, (%rdi)
	xorl	(%rsi), %eax
	movl	%eax, (%rsi)
	xorl	%eax, (%rdi)
	ret
	.cfi_endproc
.LFE51:
	.size	s, .-s
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d"
.LC1:
	.string	"%d%d"
.LC2:
	.string	"%d\n"
.LC3:
	.string	"%d%d%d%d"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB53:
	.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
	leaq	H(%rip), %r14
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	leaq	.LC0(%rip), %r12
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	leaq	Q(%rip), %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	leaq	S(%rip), %rbx
	subq	$8, %rsp
	.cfi_def_cfa_offset 64
	.p2align 4,,10
	.p2align 3
.L5:
	leaq	K(%rip), %r8
	movq	%r14, %rcx
	xorl	%eax, %eax
	leaq	M(%rip), %rdx
	leaq	N(%rip), %rsi
	leaq	.LC3(%rip), %rdi
	call	__isoc99_scanf@PLT
	movl	N(%rip), %eax
	testl	%eax, %eax
	je	.L39
	movl	$0, i(%rip)
	movl	$0, %edx
	leaq	P(%rip), %r13
	jle	.L9
	.p2align 4,,10
	.p2align 3
.L6:
	leaq	(%rbx,%rdx,4), %rsi
	xorl	%eax, %eax
	movq	%r12, %rdi
	call	__isoc99_scanf@PLT
	movl	i(%rip), %ecx
	leal	1(%rcx), %eax
	cmpl	N(%rip), %eax
	movslq	%eax, %rdx
	movl	%eax, i(%rip)
	movl	%ecx, 0(%r13,%rdx,4)
	jl	.L6
.L9:
	movslq	M(%rip), %rsi
	xorl	%eax, %eax
	movl	$0, i(%rip)
	leaq	Y(%rip), %r15
	leaq	.LC1(%rip), %r13
	testl	%esi, %esi
	jle	.L8
	.p2align 4,,10
	.p2align 3
.L7:
	cltq
	movq	%r13, %rdi
	salq	$3, %rax
	leaq	4(%r15,%rax), %rdx
	leaq	(%r15,%rax), %rsi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movslq	i(%rip), %rdx
	movslq	M(%rip), %rsi
	movq	%rdx, %rax
	subl	$1, (%r15,%rdx,8)
	addl	$1, %eax
	movl	%eax, i(%rip)
	cmpl	%esi, %eax
	jl	.L7
.L8:
	leaq	c(%rip), %rcx
	movl	$8, %edx
	movq	%r15, %rdi
	call	qsort@PLT
	movl	M(%rip), %r9d
	testl	%r9d, %r9d
	jle	.L10
	movslq	%r9d, %r8
	xorl	%ecx, %ecx
	leaq	P(%rip), %r13
	leaq	W(%rip), %rdi
	.p2align 4,,10
	.p2align 3
.L11:
	movslq	(%r15,%rcx,8), %rsi
	movq	0(%r13,%rsi,4), %xmm0
	movq	%rsi, %rdx
	addl	$1, %edx
	movd	%xmm0, %eax
	pshufd	$0xe5, %xmm0, %xmm1
	movslq	%edx, %rdx
	movd	%xmm1, %r10d
	xorl	%r10d, %eax
	movq	%xmm0, (%rdi,%rcx,8)
	addq	$1, %rcx
	movl	%eax, 0(%r13,%rsi,4)
	xorl	0(%r13,%rdx,4), %eax
	movl	%eax, 0(%r13,%rdx,4)
	xorl	%eax, 0(%r13,%rsi,4)
	cmpq	%rcx, %r8
	jne	.L11
.L10:
	movslq	N(%rip), %rcx
	testl	%ecx, %ecx
	jle	.L12
	xorl	%eax, %eax
	leaq	P(%rip), %r13
	.p2align 4,,10
	.p2align 3
.L13:
	movslq	0(%r13,%rax,4), %rdx
	movl	%eax, 0(%rbp,%rdx,4)
	addq	$1, %rax
	cmpq	%rax, %rcx
	jne	.L13
.L12:
	movl	K(%rip), %r10d
	movl	$0, R(%rip)
	testl	%r10d, %r10d
	jle	.L24
	leaq	Q(%rip), %rax
	leal	-1(%r10), %edx
	leaq	4(%rax), %rcx
	leaq	(%rcx,%rdx,4), %rsi
	xorl	%ecx, %ecx
	.p2align 4,,10
	.p2align 3
.L15:
	movslq	(%rax), %rdx
	addq	$4, %rax
	addl	(%rbx,%rdx,4), %ecx
	cmpq	%rax, %rsi
	jne	.L15
	movl	%ecx, R(%rip)
.L14:
	movl	$0, i(%rip)
	movl	%ecx, t(%rip)
	movl	%ecx, r(%rip)
	testl	%r9d, %r9d
	jle	.L25
	leaq	W(%rip), %rax
	leal	-1(%r9), %edx
	movl	%ecx, %r8d
	leaq	8(%rax), %rsi
	leaq	(%rsi,%rdx,8), %r11
	jmp	.L19
	.p2align 4,,10
	.p2align 3
.L41:
	movl	%ecx, %edx
	cmpl	%r10d, %edi
	jl	.L18
	movslq	%esi, %rdx
	movslq	%edi, %r13
	movl	%ecx, %r15d
	movslq	0(%rbp,%rdx,4), %rdx
	movslq	0(%rbp,%r13,4), %r13
	subl	(%rbx,%rdx,4), %r15d
	movl	%r15d, %edx
	addl	(%rbx,%r13,4), %edx
.L18:
	cmpl	%edx, %r8d
	cmovg	%edx, %r8d
	addq	$8, %rax
	cmpq	%rax, %r11
	je	.L40
.L19:
	movl	(%rax), %esi
	movl	4(%rax), %edi
	cmpl	%r10d, %esi
	jl	.L41
	movl	%ecx, %edx
	cmpl	%r10d, %edi
	jge	.L18
	movslq	%edi, %rdx
	movslq	%esi, %r13
	movl	%ecx, %r15d
	movslq	0(%rbp,%rdx,4), %rdx
	movslq	0(%rbp,%r13,4), %r13
	subl	(%rbx,%rdx,4), %r15d
	movl	%r15d, %edx
	addl	(%rbx,%r13,4), %edx
	cmpl	%edx, %r8d
	cmovg	%edx, %r8d
	addq	$8, %rax
	cmpq	%rax, %r11
	jne	.L19
.L40:
	movl	%r8d, R(%rip)
	movl	%r9d, i(%rip)
	movl	%edi, y(%rip)
	movl	%esi, x(%rip)
.L16:
	movl	%r8d, %edx
	leaq	.LC2(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L5
	.p2align 4,,10
	.p2align 3
.L39:
	addq	$8, %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
.L25:
	.cfi_restore_state
	movl	%ecx, %r8d
	jmp	.L16
	.p2align 4,,10
	.p2align 3
.L24:
	xorl	%ecx, %ecx
	jmp	.L14
	.cfi_endproc
.LFE53:
	.size	main, .-main
	.globl	y
	.bss
	.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	r
	.align 4
	.type	r, @object
	.size	r, 4
r:
	.zero	4
	.globl	t
	.align 4
	.type	t, @object
	.size	t, 4
t:
	.zero	4
	.globl	R
	.align 4
	.type	R, @object
	.size	R, 4
R:
	.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	Q
	.align 32
	.type	Q, @object
	.size	Q, 4004
Q:
	.zero	4004
	.globl	P
	.align 32
	.type	P, @object
	.size	P, 4004
P:
	.zero	4004
	.globl	W
	.align 32
	.type	W, @object
	.size	W, 800008
W:
	.zero	800008
	.globl	Y
	.align 32
	.type	Y, @object
	.size	Y, 800008
Y:
	.zero	800008
	.globl	S
	.align 32
	.type	S, @object
	.size	S, 4004
S:
	.zero	4004
	.globl	K
	.align 4
	.type	K, @object
	.size	K, 4
K:
	.zero	4
	.globl	H
	.align 4
	.type	H, @object
	.size	H, 4
H:
	.zero	4
	.globl	M
	.align 4
	.type	M, @object
	.size	M, 4
M:
	.zero	4
	.globl	N
	.align 4
	.type	N, @object
	.size	N, 4
N:
	.zero	4
	.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	c
	.type	c, @function
c:
.LFB52:
	.cfi_startproc
	endbr64
	movl	4(%rdi), %eax
	subl	4(%rsi), %eax
	ret
	.cfi_endproc
.LFE52:
	.size	c, .-c
	.p2align 4
	.globl	s
	.type	s, @function
s:
.LFB51:
	.cfi_startproc
	endbr64
	movl	(%rdi), %eax
	xorl	(%rsi), %eax
	movl	%eax, (%rdi)
	xorl	(%rsi), %eax
	movl	%eax, (%rsi)
	xorl	%eax, (%rdi)
	ret
	.cfi_endproc
.LFE51:
	.size	s, .-s
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d"
.LC1:
	.string	"%d%d"
.LC2:
	.string	"%d\n"
.LC3:
	.string	"%d%d%d%d"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB53:
	.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
	leaq	H(%rip), %r14
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	leaq	.LC0(%rip), %r12
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	leaq	Q(%rip), %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	leaq	S(%rip), %rbx
	subq	$8, %rsp
	.cfi_def_cfa_offset 64
	.p2align 4,,10
	.p2align 3
.L5:
	leaq	K(%rip), %r8
	movq	%r14, %rcx
	xorl	%eax, %eax
	leaq	M(%rip), %rdx
	leaq	N(%rip), %rsi
	leaq	.LC3(%rip), %rdi
	call	__isoc99_scanf@PLT
	movl	N(%rip), %eax
	testl	%eax, %eax
	je	.L39
	movl	$0, i(%rip)
	movl	$0, %edx
	leaq	P(%rip), %r13
	jle	.L9
	.p2align 4,,10
	.p2align 3
.L6:
	leaq	(%rbx,%rdx,4), %rsi
	xorl	%eax, %eax
	movq	%r12, %rdi
	call	__isoc99_scanf@PLT
	movl	i(%rip), %ecx
	leal	1(%rcx), %eax
	cmpl	N(%rip), %eax
	movslq	%eax, %rdx
	movl	%eax, i(%rip)
	movl	%ecx, 0(%r13,%rdx,4)
	jl	.L6
.L9:
	movslq	M(%rip), %rsi
	xorl	%eax, %eax
	movl	$0, i(%rip)
	leaq	Y(%rip), %r15
	leaq	.LC1(%rip), %r13
	testl	%esi, %esi
	jle	.L8
	.p2align 4,,10
	.p2align 3
.L7:
	cltq
	movq	%r13, %rdi
	salq	$3, %rax
	leaq	4(%r15,%rax), %rdx
	leaq	(%r15,%rax), %rsi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movslq	i(%rip), %rdx
	movslq	M(%rip), %rsi
	movq	%rdx, %rax
	subl	$1, (%r15,%rdx,8)
	addl	$1, %eax
	movl	%eax, i(%rip)
	cmpl	%esi, %eax
	jl	.L7
.L8:
	leaq	c(%rip), %rcx
	movl	$8, %edx
	movq	%r15, %rdi
	call	qsort@PLT
	movl	M(%rip), %r9d
	testl	%r9d, %r9d
	jle	.L10
	movslq	%r9d, %r8
	xorl	%ecx, %ecx
	leaq	P(%rip), %r13
	leaq	W(%rip), %rdi
	.p2align 4,,10
	.p2align 3
.L11:
	movslq	(%r15,%rcx,8), %rsi
	movq	0(%r13,%rsi,4), %xmm0
	movq	%rsi, %rdx
	addl	$1, %edx
	movd	%xmm0, %eax
	pshufd	$0xe5, %xmm0, %xmm1
	movslq	%edx, %rdx
	movd	%xmm1, %r10d
	xorl	%r10d, %eax
	movq	%xmm0, (%rdi,%rcx,8)
	addq	$1, %rcx
	movl	%eax, 0(%r13,%rsi,4)
	xorl	0(%r13,%rdx,4), %eax
	movl	%eax, 0(%r13,%rdx,4)
	xorl	%eax, 0(%r13,%rsi,4)
	cmpq	%rcx, %r8
	jne	.L11
.L10:
	movslq	N(%rip), %rcx
	testl	%ecx, %ecx
	jle	.L12
	xorl	%eax, %eax
	leaq	P(%rip), %r13
	.p2align 4,,10
	.p2align 3
.L13:
	movslq	0(%r13,%rax,4), %rdx
	movl	%eax, 0(%rbp,%rdx,4)
	addq	$1, %rax
	cmpq	%rax, %rcx
	jne	.L13
.L12:
	movl	K(%rip), %r10d
	movl	$0, R(%rip)
	testl	%r10d, %r10d
	jle	.L24
	leaq	Q(%rip), %rax
	leal	-1(%r10), %edx
	leaq	4(%rax), %rcx
	leaq	(%rcx,%rdx,4), %rsi
	xorl	%ecx, %ecx
	.p2align 4,,10
	.p2align 3
.L15:
	movslq	(%rax), %rdx
	addq	$4, %rax
	addl	(%rbx,%rdx,4), %ecx
	cmpq	%rax, %rsi
	jne	.L15
	movl	%ecx, R(%rip)
.L14:
	movl	$0, i(%rip)
	movl	%ecx, t(%rip)
	movl	%ecx, r(%rip)
	testl	%r9d, %r9d
	jle	.L25
	leaq	W(%rip), %rax
	leal	-1(%r9), %edx
	movl	%ecx, %r8d
	leaq	8(%rax), %rsi
	leaq	(%rsi,%rdx,8), %r11
	jmp	.L19
	.p2align 4,,10
	.p2align 3
.L41:
	movl	%ecx, %edx
	cmpl	%r10d, %edi
	jl	.L18
	movslq	%esi, %rdx
	movslq	%edi, %r13
	movl	%ecx, %r15d
	movslq	0(%rbp,%rdx,4), %rdx
	movslq	0(%rbp,%r13,4), %r13
	subl	(%rbx,%rdx,4), %r15d
	movl	%r15d, %edx
	addl	(%rbx,%r13,4), %edx
.L18:
	cmpl	%edx, %r8d
	cmovg	%edx, %r8d
	addq	$8, %rax
	cmpq	%rax, %r11
	je	.L40
.L19:
	movl	(%rax), %esi
	movl	4(%rax), %edi
	cmpl	%r10d, %esi
	jl	.L41
	movl	%ecx, %edx
	cmpl	%r10d, %edi
	jge	.L18
	movslq	%edi, %rdx
	movslq	%esi, %r13
	movl	%ecx, %r15d
	movslq	0(%rbp,%rdx,4), %rdx
	movslq	0(%rbp,%r13,4), %r13
	subl	(%rbx,%rdx,4), %r15d
	movl	%r15d, %edx
	addl	(%rbx,%r13,4), %edx
	cmpl	%edx, %r8d
	cmovg	%edx, %r8d
	addq	$8, %rax
	cmpq	%rax, %r11
	jne	.L19
.L40:
	movl	%r8d, R(%rip)
	movl	%r9d, i(%rip)
	movl	%edi, y(%rip)
	movl	%esi, x(%rip)
.L16:
	movl	%r8d, %edx
	leaq	.LC2(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L5
	.p2align 4,,10
	.p2align 3
.L39:
	addq	$8, %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
.L25:
	.cfi_restore_state
	movl	%ecx, %r8d
	jmp	.L16
	.p2align 4,,10
	.p2align 3
.L24:
	xorl	%ecx, %ecx
	jmp	.L14
	.cfi_endproc
.LFE53:
	.size	main, .-main
	.globl	y
	.bss
	.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	r
	.align 4
	.type	r, @object
	.size	r, 4
r:
	.zero	4
	.globl	t
	.align 4
	.type	t, @object
	.size	t, 4
t:
	.zero	4
	.globl	R
	.align 4
	.type	R, @object
	.size	R, 4
R:
	.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	Q
	.align 32
	.type	Q, @object
	.size	Q, 4004
Q:
	.zero	4004
	.globl	P
	.align 32
	.type	P, @object
	.size	P, 4004
P:
	.zero	4004
	.globl	W
	.align 32
	.type	W, @object
	.size	W, 800008
W:
	.zero	800008
	.globl	Y
	.align 32
	.type	Y, @object
	.size	Y, 800008
Y:
	.zero	800008
	.globl	S
	.align 32
	.type	S, @object
	.size	S, 4004
S:
	.zero	4004
	.globl	K
	.align 4
	.type	K, @object
	.size	K, 4
K:
	.zero	4
	.globl	H
	.align 4
	.type	H, @object
	.size	H, 4
H:
	.zero	4
	.globl	M
	.align 4
	.type	M, @object
	.size	M, 4
M:
	.zero	4
	.globl	N
	.align 4
	.type	N, @object
	.size	N, 4
N:
	.zero	4
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int N,M,H,K,S[1001],Y[100001][2],W[100001][2],P[1001],Q[1001],i,j,R,t,r,x,y;
void s(int *a,int *b){*a^=*b^=*a^=*b;}
int c(const void *a, const void *b){return ((int*)a)[1]-((int*)b)[1];}
int main()
{
	for(;scanf("%d%d%d%d",&N,&M,&H,&K),N;)
	{
		for(i=0;i<N;S[i],P[i]=i++)scanf("%d",&S[i]);
		for(i=0;i<M;Y[i][0]--,i++)scanf("%d%d",&Y[i][0],&Y[i][1]);
		qsort(Y,M,sizeof(int[2]),c);
		for(i=0;i<M;i++)
		{
			W[i][0]=P[Y[i][0]];
			W[i][1]=P[Y[i][0]+1];
			s(&P[Y[i][0]],&P[Y[i][0]+1]);
		}
		for(i=0;i<N;i++)Q[P[i]]=i;
		for(i=R=0;i<K;i++)R+=S[Q[i]];
		for(i=0,r=t=R;i<M;i++,t=r)
		{
			x=W[i][0],y=W[i][1];
			if(x<K&&y>=K)t=t-S[Q[x]]+S[Q[y]];
			if(y<K&&x>=K)t=t-S[Q[y]]+S[Q[x]];
			R=R>t?t:R;
		}
		printf("%d\n",R);
	}
	return 0;
}
4 5 7 2
20
80
100
50
1 1
2 6
2 3
1 5
3 1
2 2 5 1
10
19
1 1
1 3
0 0 0 0
 4 5 7 2
38
80
100
50
1 1
2 6
2 3
1 5
3 1
2 2 5 1
10
19
1 1
1 3
0 0 0 0
 4 5 7 2
38
80
100
50
1 1
2 4
2 3
1 5
3 1
2 2 5 0
10
19
1 1
1 3
0 0 0 0
 4 5 7 2
20
80
100
50
2 1
2 6
3 8
1 5
3 1
2 2 5 1
10
19
1 1
1 3
0 0 0 0
 4 5 7 2
20
80
100
50
2 1
2 6
3 8
1 5
3 1
2 2 5 1
16
19
1 1
1 3
0 0 0 0
 4 5 7 2
27
80
100
50
1 1
2 4
2 3
1 5
3 1
2 2 16 0
10
19
1 1
1 3
0 0 0 0
 4 5 7 2
20
80
100
50
2 1
2 6
3 8
1 5
3 0
2 2 5 1
12
34
1 1
1 3
0 0 0 0
 4 5 12 2
20
80
100
50
1 1
2 6
2 2
1 5
3 1
2 0 5 1
10
20
1 1
1 0
0 0 0 0
 4 5 7 2
20
80
100
50
2 1
2 6
4 8
1 5
3 1
2 2 5 1
16
19
1 1
1 3
0 0 0 0
 4 5 7 2
38
80
100
50
2 1
2 6
3 8
1 5
3 0
2 2 5 1
16
34
1 1
1 3
0 0 0 0

70
10
 88
10
 130
0
 70
10
 70
16
 130
0
 70
12
 70
20
0
 70
16
 88
16

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

```c
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int N,M,H,K,S[1001],Y[100001][2],W[100001][2],P[1001],Q[1001],i,j,R,t,r,x,y;
void s(int *a,int *b){*a^=*b^=*a^=*b;}
int c(const void *a, const void *b){return ((int*)a)[1]-((int*)b)[1];}
int main()
{
	for(;scanf("%d%d%d%d",&N,&M,&H,&K),N;)
	{
		for(i=0;i<N;S[i],P[i]=i++)scanf("%d",&S[i]);
		for(i=0;i<M;Y[i][0]--,i++)scanf("%d%d",&Y[i][0],&Y[i][1]);
		qsort(Y,M,sizeof(int[2]),c);
		for(i=0;i<M;i++)
		{
			W[i][0]=P[Y[i][0]];
			W[i][1]=P[Y[i][0]+1];
			s(&P[Y[i][0]],&P[Y[i][0]+1]);
		}
		for(i=0;i<N;i++)Q[P[i]]=i;
		for(i=R=0;i<K;i++)R+=S[Q[i]];
		for(i=0,r=t=R;i<M;i++,t=r)
		{
			x=W[i][0],y=W[i][1];
			if(x<K&&y>=K)t=t-S[Q[x]]+S[Q[y]];
			if(y<K&&x>=K)t=t-S[Q[y]]+S[Q[x]];
			R=R>t?t:R;
		}
		printf("%d\n",R);
	}
	return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	N
	.bss
	.align 4
	.type	N, @object
	.size	N, 4
N:
	.zero	4
	.globl	M
	.align 4
	.type	M, @object
	.size	M, 4
M:
	.zero	4
	.globl	H
	.align 4
	.type	H, @object
	.size	H, 4
H:
	.zero	4
	.globl	K
	.align 4
	.type	K, @object
	.size	K, 4
K:
	.zero	4
	.globl	S
	.align 32
	.type	S, @object
	.size	S, 4004
S:
	.zero	4004
	.globl	Y
	.align 32
	.type	Y, @object
	.size	Y, 800008
Y:
	.zero	800008
	.globl	W
	.align 32
	.type	W, @object
	.size	W, 800008
W:
	.zero	800008
	.globl	P
	.align 32
	.type	P, @object
	.size	P, 4004
P:
	.zero	4004
	.globl	Q
	.align 32
	.type	Q, @object
	.size	Q, 4004
Q:
	.zero	4004
	.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	R
	.align 4
	.type	R, @object
	.size	R, 4
R:
	.zero	4
	.globl	t
	.align 4
	.type	t, @object
	.size	t, 4
t:
	.zero	4
	.globl	r
	.align 4
	.type	r, @object
	.size	r, 4
r:
	.zero	4
	.globl	x
	.align 4
	.type	x, @object
	.size	x, 4
x:
	.zero	4
	.globl	y
	.align 4
	.type	y, @object
	.size	y, 4
y:
	.zero	4
	.text
	.globl	s
	.type	s, @function
s:
.LFB6:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movq	%rdi, -8(%rbp)
	movq	%rsi, -16(%rbp)
	movq	-8(%rbp), %rax
	movl	(%rax), %edx
	movq	-16(%rbp), %rax
	movl	(%rax), %eax
	xorl	%eax, %edx
	movq	-8(%rbp), %rax
	movl	%edx, (%rax)
	movq	-8(%rbp), %rax
	movl	(%rax), %edx
	movq	-16(%rbp), %rax
	movl	(%rax), %eax
	xorl	%eax, %edx
	movq	-16(%rbp), %rax
	movl	%edx, (%rax)
	movq	-16(%rbp), %rax
	movl	(%rax), %edx
	movq	-8(%rbp), %rax
	movl	(%rax), %eax
	xorl	%eax, %edx
	movq	-8(%rbp), %rax
	movl	%edx, (%rax)
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	s, .-s
	.globl	c
	.type	c, @function
c:
.LFB7:
	.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
	addq	$4, %rax
	movl	(%rax), %eax
	movq	-16(%rbp), %rdx
	addq	$4, %rdx
	movl	(%rdx), %edx
	subl	%edx, %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.size	c, .-c
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%d%d"
.LC2:
	.string	"%d\n"
.LC3:
	.string	"%d%d%d%d"
	.text
	.globl	main
	.type	main, @function
main:
.LFB8:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	jmp	.L5
.L20:
	movl	$0, i(%rip)
	jmp	.L6
.L7:
	movl	i(%rip), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	S(%rip), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	i(%rip), %eax
	leal	1(%rax), %edx
	movl	%edx, i(%rip)
	movl	i(%rip), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	P(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
.L6:
	movl	i(%rip), %edx
	movl	N(%rip), %eax
	cmpl	%eax, %edx
	jl	.L7
	movl	$0, i(%rip)
	jmp	.L8
.L9:
	movl	i(%rip), %eax
	cltq
	salq	$3, %rax
	leaq	4(%rax), %rdx
	leaq	Y(%rip), %rax
	addq	%rax, %rdx
	movl	i(%rip), %eax
	cltq
	leaq	0(,%rax,8), %rcx
	leaq	Y(%rip), %rax
	addq	%rcx, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	i(%rip), %eax
	movslq	%eax, %rdx
	leaq	0(,%rdx,8), %rcx
	leaq	Y(%rip), %rdx
	movl	(%rcx,%rdx), %edx
	leal	-1(%rdx), %ecx
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	Y(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	movl	i(%rip), %eax
	addl	$1, %eax
	movl	%eax, i(%rip)
.L8:
	movl	i(%rip), %edx
	movl	M(%rip), %eax
	cmpl	%eax, %edx
	jl	.L9
	movl	M(%rip), %eax
	cltq
	leaq	c(%rip), %rdx
	movq	%rdx, %rcx
	movl	$8, %edx
	movq	%rax, %rsi
	leaq	Y(%rip), %rax
	movq	%rax, %rdi
	call	qsort@PLT
	movl	$0, i(%rip)
	jmp	.L10
.L11:
	movl	i(%rip), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	Y(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	i(%rip), %edx
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	P(%rip), %rax
	movl	(%rcx,%rax), %eax
	movslq	%edx, %rdx
	leaq	0(,%rdx,8), %rcx
	leaq	W(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	movl	i(%rip), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	Y(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	$1, %eax
	movl	i(%rip), %edx
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	P(%rip), %rax
	movl	(%rcx,%rax), %eax
	movslq	%edx, %rdx
	leaq	0(,%rdx,8), %rcx
	leaq	4+W(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	movl	i(%rip), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	Y(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	$1, %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	P(%rip), %rax
	addq	%rax, %rdx
	movl	i(%rip), %eax
	cltq
	leaq	0(,%rax,8), %rcx
	leaq	Y(%rip), %rax
	movl	(%rcx,%rax), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	P(%rip), %rax
	addq	%rcx, %rax
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	s
	movl	i(%rip), %eax
	addl	$1, %eax
	movl	%eax, i(%rip)
.L10:
	movl	i(%rip), %edx
	movl	M(%rip), %eax
	cmpl	%eax, %edx
	jl	.L11
	movl	$0, i(%rip)
	jmp	.L12
.L13:
	movl	i(%rip), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	P(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	i(%rip), %eax
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	Q(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	movl	i(%rip), %eax
	addl	$1, %eax
	movl	%eax, i(%rip)
.L12:
	movl	i(%rip), %edx
	movl	N(%rip), %eax
	cmpl	%eax, %edx
	jl	.L13
	movl	$0, R(%rip)
	movl	R(%rip), %eax
	movl	%eax, i(%rip)
	jmp	.L14
.L15:
	movl	i(%rip), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	Q(%rip), %rax
	movl	(%rdx,%rax), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	S(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	R(%rip), %eax
	addl	%edx, %eax
	movl	%eax, R(%rip)
	movl	i(%rip), %eax
	addl	$1, %eax
	movl	%eax, i(%rip)
.L14:
	movl	i(%rip), %edx
	movl	K(%rip), %eax
	cmpl	%eax, %edx
	jl	.L15
	movl	$0, i(%rip)
	movl	R(%rip), %eax
	movl	%eax, t(%rip)
	movl	t(%rip), %eax
	movl	%eax, r(%rip)
	jmp	.L16
.L19:
	movl	i(%rip), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	W(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, x(%rip)
	movl	i(%rip), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	4+W(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, y(%rip)
	movl	x(%rip), %edx
	movl	K(%rip), %eax
	cmpl	%eax, %edx
	jge	.L17
	movl	y(%rip), %edx
	movl	K(%rip), %eax
	cmpl	%eax, %edx
	jl	.L17
	movl	t(%rip), %eax
	movl	x(%rip), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	Q(%rip), %rdx
	movl	(%rcx,%rdx), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	S(%rip), %rdx
	movl	(%rcx,%rdx), %edx
	subl	%edx, %eax
	movl	%eax, %ecx
	movl	y(%rip), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	Q(%rip), %rax
	movl	(%rdx,%rax), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	S(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	%ecx, %eax
	movl	%eax, t(%rip)
.L17:
	movl	y(%rip), %edx
	movl	K(%rip), %eax
	cmpl	%eax, %edx
	jge	.L18
	movl	x(%rip), %edx
	movl	K(%rip), %eax
	cmpl	%eax, %edx
	jl	.L18
	movl	t(%rip), %eax
	movl	y(%rip), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	Q(%rip), %rdx
	movl	(%rcx,%rdx), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	S(%rip), %rdx
	movl	(%rcx,%rdx), %edx
	subl	%edx, %eax
	movl	%eax, %ecx
	movl	x(%rip), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	Q(%rip), %rax
	movl	(%rdx,%rax), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	S(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	%ecx, %eax
	movl	%eax, t(%rip)
.L18:
	movl	R(%rip), %edx
	movl	t(%rip), %eax
	cmpl	%eax, %edx
	cmovle	%edx, %eax
	movl	%eax, R(%rip)
	movl	i(%rip), %eax
	addl	$1, %eax
	movl	%eax, i(%rip)
	movl	r(%rip), %eax
	movl	%eax, t(%rip)
.L16:
	movl	i(%rip), %edx
	movl	M(%rip), %eax
	cmpl	%eax, %edx
	jl	.L19
	movl	R(%rip), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L5:
	leaq	K(%rip), %r8
	leaq	H(%rip), %rax
	movq	%rax, %rcx
	leaq	M(%rip), %rax
	movq	%rax, %rdx
	leaq	N(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	N(%rip), %eax
	testl	%eax, %eax
	jne	.L20
	movl	$0, %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE8:
	.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	N
	.bss
	.align 4
	.type	N, @object
	.size	N, 4
N:
	.zero	4
	.globl	M
	.align 4
	.type	M, @object
	.size	M, 4
M:
	.zero	4
	.globl	H
	.align 4
	.type	H, @object
	.size	H, 4
H:
	.zero	4
	.globl	K
	.align 4
	.type	K, @object
	.size	K, 4
K:
	.zero	4
	.globl	S
	.align 32
	.type	S, @object
	.size	S, 4004
S:
	.zero	4004
	.globl	Y
	.align 32
	.type	Y, @object
	.size	Y, 800008
Y:
	.zero	800008
	.globl	W
	.align 32
	.type	W, @object
	.size	W, 800008
W:
	.zero	800008
	.globl	P
	.align 32
	.type	P, @object
	.size	P, 4004
P:
	.zero	4004
	.globl	Q
	.align 32
	.type	Q, @object
	.size	Q, 4004
Q:
	.zero	4004
	.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	R
	.align 4
	.type	R, @object
	.size	R, 4
R:
	.zero	4
	.globl	t
	.align 4
	.type	t, @object
	.size	t, 4
t:
	.zero	4
	.globl	r
	.align 4
	.type	r, @object
	.size	r, 4
r:
	.zero	4
	.globl	x
	.align 4
	.type	x, @object
	.size	x, 4
x:
	.zero	4
	.globl	y
	.align 4
	.type	y, @object
	.size	y, 4
y:
	.zero	4
	.text
	.globl	s
	.type	s, @function
s:
.LFB6:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movq	%rdi, -8(%rbp)
	movq	%rsi, -16(%rbp)
	movq	-8(%rbp), %rax
	movl	(%rax), %edx
	movq	-16(%rbp), %rax
	movl	(%rax), %eax
	xorl	%eax, %edx
	movq	-8(%rbp), %rax
	movl	%edx, (%rax)
	movq	-8(%rbp), %rax
	movl	(%rax), %edx
	movq	-16(%rbp), %rax
	movl	(%rax), %eax
	xorl	%eax, %edx
	movq	-16(%rbp), %rax
	movl	%edx, (%rax)
	movq	-16(%rbp), %rax
	movl	(%rax), %edx
	movq	-8(%rbp), %rax
	movl	(%rax), %eax
	xorl	%eax, %edx
	movq	-8(%rbp), %rax
	movl	%edx, (%rax)
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	s, .-s
	.globl	c
	.type	c, @function
c:
.LFB7:
	.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
	addq	$4, %rax
	movl	(%rax), %eax
	movq	-16(%rbp), %rdx
	addq	$4, %rdx
	movl	(%rdx), %edx
	subl	%edx, %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.size	c, .-c
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%d%d"
.LC2:
	.string	"%d\n"
.LC3:
	.string	"%d%d%d%d"
	.text
	.globl	main
	.type	main, @function
main:
.LFB8:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	jmp	.L5
.L20:
	movl	$0, i(%rip)
	jmp	.L6
.L7:
	movl	i(%rip), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	S(%rip), %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	i(%rip), %eax
	leal	1(%rax), %edx
	movl	%edx, i(%rip)
	movl	i(%rip), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	P(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
.L6:
	movl	i(%rip), %edx
	movl	N(%rip), %eax
	cmpl	%eax, %edx
	jl	.L7
	movl	$0, i(%rip)
	jmp	.L8
.L9:
	movl	i(%rip), %eax
	cltq
	salq	$3, %rax
	leaq	4(%rax), %rdx
	leaq	Y(%rip), %rax
	addq	%rax, %rdx
	movl	i(%rip), %eax
	cltq
	leaq	0(,%rax,8), %rcx
	leaq	Y(%rip), %rax
	addq	%rcx, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	i(%rip), %eax
	movslq	%eax, %rdx
	leaq	0(,%rdx,8), %rcx
	leaq	Y(%rip), %rdx
	movl	(%rcx,%rdx), %edx
	leal	-1(%rdx), %ecx
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	Y(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	movl	i(%rip), %eax
	addl	$1, %eax
	movl	%eax, i(%rip)
.L8:
	movl	i(%rip), %edx
	movl	M(%rip), %eax
	cmpl	%eax, %edx
	jl	.L9
	movl	M(%rip), %eax
	cltq
	leaq	c(%rip), %rdx
	movq	%rdx, %rcx
	movl	$8, %edx
	movq	%rax, %rsi
	leaq	Y(%rip), %rax
	movq	%rax, %rdi
	call	qsort@PLT
	movl	$0, i(%rip)
	jmp	.L10
.L11:
	movl	i(%rip), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	Y(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	i(%rip), %edx
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	P(%rip), %rax
	movl	(%rcx,%rax), %eax
	movslq	%edx, %rdx
	leaq	0(,%rdx,8), %rcx
	leaq	W(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	movl	i(%rip), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	Y(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	$1, %eax
	movl	i(%rip), %edx
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	P(%rip), %rax
	movl	(%rcx,%rax), %eax
	movslq	%edx, %rdx
	leaq	0(,%rdx,8), %rcx
	leaq	4+W(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	movl	i(%rip), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	Y(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	$1, %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	P(%rip), %rax
	addq	%rax, %rdx
	movl	i(%rip), %eax
	cltq
	leaq	0(,%rax,8), %rcx
	leaq	Y(%rip), %rax
	movl	(%rcx,%rax), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	P(%rip), %rax
	addq	%rcx, %rax
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	s
	movl	i(%rip), %eax
	addl	$1, %eax
	movl	%eax, i(%rip)
.L10:
	movl	i(%rip), %edx
	movl	M(%rip), %eax
	cmpl	%eax, %edx
	jl	.L11
	movl	$0, i(%rip)
	jmp	.L12
.L13:
	movl	i(%rip), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	P(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	i(%rip), %eax
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	Q(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	movl	i(%rip), %eax
	addl	$1, %eax
	movl	%eax, i(%rip)
.L12:
	movl	i(%rip), %edx
	movl	N(%rip), %eax
	cmpl	%eax, %edx
	jl	.L13
	movl	$0, R(%rip)
	movl	R(%rip), %eax
	movl	%eax, i(%rip)
	jmp	.L14
.L15:
	movl	i(%rip), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	Q(%rip), %rax
	movl	(%rdx,%rax), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	S(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	R(%rip), %eax
	addl	%edx, %eax
	movl	%eax, R(%rip)
	movl	i(%rip), %eax
	addl	$1, %eax
	movl	%eax, i(%rip)
.L14:
	movl	i(%rip), %edx
	movl	K(%rip), %eax
	cmpl	%eax, %edx
	jl	.L15
	movl	$0, i(%rip)
	movl	R(%rip), %eax
	movl	%eax, t(%rip)
	movl	t(%rip), %eax
	movl	%eax, r(%rip)
	jmp	.L16
.L19:
	movl	i(%rip), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	W(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, x(%rip)
	movl	i(%rip), %eax
	cltq
	leaq	0(,%rax,8), %rdx
	leaq	4+W(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, y(%rip)
	movl	x(%rip), %edx
	movl	K(%rip), %eax
	cmpl	%eax, %edx
	jge	.L17
	movl	y(%rip), %edx
	movl	K(%rip), %eax
	cmpl	%eax, %edx
	jl	.L17
	movl	t(%rip), %eax
	movl	x(%rip), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	Q(%rip), %rdx
	movl	(%rcx,%rdx), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	S(%rip), %rdx
	movl	(%rcx,%rdx), %edx
	subl	%edx, %eax
	movl	%eax, %ecx
	movl	y(%rip), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	Q(%rip), %rax
	movl	(%rdx,%rax), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	S(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	%ecx, %eax
	movl	%eax, t(%rip)
.L17:
	movl	y(%rip), %edx
	movl	K(%rip), %eax
	cmpl	%eax, %edx
	jge	.L18
	movl	x(%rip), %edx
	movl	K(%rip), %eax
	cmpl	%eax, %edx
	jl	.L18
	movl	t(%rip), %eax
	movl	y(%rip), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	Q(%rip), %rdx
	movl	(%rcx,%rdx), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	S(%rip), %rdx
	movl	(%rcx,%rdx), %edx
	subl	%edx, %eax
	movl	%eax, %ecx
	movl	x(%rip), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	Q(%rip), %rax
	movl	(%rdx,%rax), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	S(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	%ecx, %eax
	movl	%eax, t(%rip)
.L18:
	movl	R(%rip), %edx
	movl	t(%rip), %eax
	cmpl	%eax, %edx
	cmovle	%edx, %eax
	movl	%eax, R(%rip)
	movl	i(%rip), %eax
	addl	$1, %eax
	movl	%eax, i(%rip)
	movl	r(%rip), %eax
	movl	%eax, t(%rip)
.L16:
	movl	i(%rip), %edx
	movl	M(%rip), %eax
	cmpl	%eax, %edx
	jl	.L19
	movl	R(%rip), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L5:
	leaq	K(%rip), %r8
	leaq	H(%rip), %rax
	movq	%rax, %rcx
	leaq	M(%rip), %rax
	movq	%rax, %rdx
	leaq	N(%rip), %rax
	movq	%rax, %rsi
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	N(%rip), %eax
	testl	%eax, %eax
	jne	.L20
	movl	$0, %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE8:
	.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:
