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>
#define df 0
#define MAX 100000

int q[2][MAX];
int head[2]={},tail[2]={};
void enq(int a,int t);
int deq(int t);
void enq(int a,int t){
  q[t][tail[t]++]=a;
}
int deq(int t){
  return q[t][head[t]++];
}
int comp(const void *a,const void *b){
  int x=*((int*)a), y=*((int*)b);
  return (x-y)*x;
}

int main(){
  int n;
  scanf("%d",&n);
  int i;  
  for(i=0;i<n;i++){
    int a;
    scanf("%d",&a);
    if(a>0) enq(a,0);
    else enq(a,1);
  }
  qsort(q[0],tail[0],sizeof(int),comp);
  qsort(q[1],tail[1],sizeof(int),comp);
  if(tail[0]==0){
    enq(deq(1),0);
  }
  if(tail[1]==0){
    enq(deq(0),1);
  }
  if(df){
    int t;
    for(t=0;t<2;t++){
    printf("q[%d]:[",t);
      for(i=head[t];i<tail[t];i++)printf(" %d",q[t][i]);
      printf(" ]\n");
    }
  }
  int s=0;
  for(i=head[0];i<tail[0];i++){
    s+=q[0][i];
  }
  for(i=head[1];i<tail[1];i++){
    s-=q[1][i];
  }
  printf("%d\n",s);
  while(tail[0]-head[0]>1){
    int a=deq(0),b=deq(1);
    printf("%d %d\n",b,a);
    enq(b-a,1);
  if(df){
    int t;
    for(t=0;t<2;t++){
    printf("q[%d]:[",t);
      for(i=head[t];i<tail[t];i++)printf(" %d",q[t][i]);
      printf(" ]\n");
    }
  }
  }
  while(tail[1]-head[1]>1){
    int a=deq(0),b=deq(1);
    printf("%d %d\n",a,b);
    enq(a-b,0);
    if(df){
      int t;
      for(t=0;t<2;t++){
	printf("q[%d]:[",t);
	for(i=head[t];i<tail[t];i++)printf(" %d",q[t][i]);
	printf(" ]\n");
      }
    }
  }
  printf("%d %d\n",q[0][head[0]],q[1][head[1]]);
}



```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	q
	.bss
	.align 32
	.type	q, @object
	.size	q, 800000
q:
	.zero	800000
	.globl	head
	.align 8
	.type	head, @object
	.size	head, 8
head:
	.zero	8
	.globl	tail
	.align 8
	.type	tail, @object
	.size	tail, 8
tail:
	.zero	8
	.text
	.globl	enq
	.type	enq, @function
enq:
.LFB6:
	.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), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	tail(%rip), %rax
	movl	(%rdx,%rax), %eax
	leal	1(%rax), %edx
	movl	-8(%rbp), %ecx
	movslq	%ecx, %rcx
	leaq	0(,%rcx,4), %rsi
	leaq	tail(%rip), %rcx
	movl	%edx, (%rsi,%rcx)
	movslq	%eax, %rdx
	movl	-8(%rbp), %eax
	cltq
	imulq	$100000, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rcx
	leaq	q(%rip), %rdx
	movl	-4(%rbp), %eax
	movl	%eax, (%rcx,%rdx)
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	enq, .-enq
	.globl	deq
	.type	deq, @function
deq:
.LFB7:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	%edi, -4(%rbp)
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	head(%rip), %rax
	movl	(%rdx,%rax), %eax
	leal	1(%rax), %edx
	movl	-4(%rbp), %ecx
	movslq	%ecx, %rcx
	leaq	0(,%rcx,4), %rsi
	leaq	head(%rip), %rcx
	movl	%edx, (%rsi,%rcx)
	movslq	%eax, %rdx
	movl	-4(%rbp), %eax
	cltq
	imulq	$100000, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	q(%rip), %rax
	movl	(%rdx,%rax), %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.size	deq, .-deq
	.globl	comp
	.type	comp, @function
comp:
.LFB8:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movq	%rdi, -24(%rbp)
	movq	%rsi, -32(%rbp)
	movq	-24(%rbp), %rax
	movl	(%rax), %eax
	movl	%eax, -8(%rbp)
	movq	-32(%rbp), %rax
	movl	(%rax), %eax
	movl	%eax, -4(%rbp)
	movl	-8(%rbp), %eax
	subl	-4(%rbp), %eax
	imull	-8(%rbp), %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE8:
	.size	comp, .-comp
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%d\n"
.LC2:
	.string	"%d %d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB9:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$48, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-40(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -28(%rbp)
	jmp	.L7
.L10:
	leaq	-36(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-36(%rbp), %eax
	testl	%eax, %eax
	jle	.L8
	movl	-36(%rbp), %eax
	movl	$0, %esi
	movl	%eax, %edi
	call	enq
	jmp	.L9
.L8:
	movl	-36(%rbp), %eax
	movl	$1, %esi
	movl	%eax, %edi
	call	enq
.L9:
	addl	$1, -28(%rbp)
.L7:
	movl	-40(%rbp), %eax
	cmpl	%eax, -28(%rbp)
	jl	.L10
	movl	tail(%rip), %eax
	cltq
	leaq	comp(%rip), %rdx
	movq	%rdx, %rcx
	movl	$4, %edx
	movq	%rax, %rsi
	leaq	q(%rip), %rax
	movq	%rax, %rdi
	call	qsort@PLT
	movl	4+tail(%rip), %eax
	cltq
	leaq	comp(%rip), %rdx
	movq	%rdx, %rcx
	movl	$4, %edx
	movq	%rax, %rsi
	leaq	400000+q(%rip), %rax
	movq	%rax, %rdi
	call	qsort@PLT
	movl	tail(%rip), %eax
	testl	%eax, %eax
	jne	.L11
	movl	$1, %edi
	call	deq
	movl	$0, %esi
	movl	%eax, %edi
	call	enq
.L11:
	movl	4+tail(%rip), %eax
	testl	%eax, %eax
	jne	.L12
	movl	$0, %edi
	call	deq
	movl	$1, %esi
	movl	%eax, %edi
	call	enq
.L12:
	movl	$0, -32(%rbp)
	movl	head(%rip), %eax
	movl	%eax, -28(%rbp)
	jmp	.L13
.L14:
	movl	-28(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	q(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	%eax, -32(%rbp)
	addl	$1, -28(%rbp)
.L13:
	movl	tail(%rip), %eax
	cmpl	%eax, -28(%rbp)
	jl	.L14
	movl	4+head(%rip), %eax
	movl	%eax, -28(%rbp)
	jmp	.L15
.L16:
	movl	-28(%rbp), %eax
	cltq
	addq	$100000, %rax
	leaq	0(,%rax,4), %rdx
	leaq	q(%rip), %rax
	movl	(%rdx,%rax), %eax
	subl	%eax, -32(%rbp)
	addl	$1, -28(%rbp)
.L15:
	movl	4+tail(%rip), %eax
	cmpl	%eax, -28(%rbp)
	jl	.L16
	movl	-32(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L17
.L18:
	movl	$0, %edi
	call	deq
	movl	%eax, -16(%rbp)
	movl	$1, %edi
	call	deq
	movl	%eax, -12(%rbp)
	movl	-16(%rbp), %edx
	movl	-12(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	-12(%rbp), %eax
	subl	-16(%rbp), %eax
	movl	$1, %esi
	movl	%eax, %edi
	call	enq
.L17:
	movl	tail(%rip), %eax
	movl	head(%rip), %edx
	subl	%edx, %eax
	cmpl	$1, %eax
	jg	.L18
	jmp	.L19
.L20:
	movl	$0, %edi
	call	deq
	movl	%eax, -24(%rbp)
	movl	$1, %edi
	call	deq
	movl	%eax, -20(%rbp)
	movl	-20(%rbp), %edx
	movl	-24(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	-24(%rbp), %eax
	subl	-20(%rbp), %eax
	movl	$0, %esi
	movl	%eax, %edi
	call	enq
.L19:
	movl	4+tail(%rip), %eax
	movl	4+head(%rip), %edx
	subl	%edx, %eax
	cmpl	$1, %eax
	jg	.L20
	movl	4+head(%rip), %eax
	cltq
	addq	$100000, %rax
	leaq	0(,%rax,4), %rdx
	leaq	q(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	head(%rip), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	q(%rip), %rax
	movl	(%rcx,%rax), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L22
	call	__stack_chk_fail@PLT
.L22:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE9:
	.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	comp
	.type	comp, @function
comp:
.LFB41:
	.cfi_startproc
	endbr64
	movl	(%rdi), %edx
	movl	%edx, %eax
	subl	(%rsi), %eax
	imull	%edx, %eax
	ret
	.cfi_endproc
.LFE41:
	.size	comp, .-comp
	.p2align 4
	.globl	enq
	.type	enq, @function
enq:
.LFB39:
	.cfi_startproc
	endbr64
	movslq	%esi, %rsi
	leaq	tail(%rip), %rdx
	movslq	(%rdx,%rsi,4), %rax
	leal	1(%rax), %ecx
	movl	%ecx, (%rdx,%rsi,4)
	imulq	$100000, %rsi, %rsi
	addq	%rax, %rsi
	leaq	q(%rip), %rax
	movl	%edi, (%rax,%rsi,4)
	ret
	.cfi_endproc
.LFE39:
	.size	enq, .-enq
	.p2align 4
	.globl	deq
	.type	deq, @function
deq:
.LFB40:
	.cfi_startproc
	endbr64
	leaq	head(%rip), %rdx
	movslq	%edi, %rdi
	movslq	(%rdx,%rdi,4), %rax
	leal	1(%rax), %ecx
	movl	%ecx, (%rdx,%rdi,4)
	imulq	$100000, %rdi, %rdi
	addq	%rax, %rdi
	leaq	q(%rip), %rax
	movl	(%rax,%rdi,4), %eax
	ret
	.cfi_endproc
.LFE40:
	.size	deq, .-deq
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d"
.LC1:
	.string	"%d\n"
.LC2:
	.string	"%d %d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB42:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	leaq	.LC0(%rip), %r12
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	movq	%r12, %rdi
	xorl	%ebp, %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	leaq	q(%rip), %rbx
	subq	$24, %rsp
	.cfi_def_cfa_offset 80
	movq	%fs:40, %rax
	movq	%rax, 8(%rsp)
	xorl	%eax, %eax
	movq	%rsp, %rsi
	leaq	4(%rsp), %r13
	call	__isoc99_scanf@PLT
	movl	(%rsp), %ecx
	testl	%ecx, %ecx
	jle	.L11
	.p2align 4,,10
	.p2align 3
.L6:
	movq	%r13, %rsi
	movq	%r12, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	4(%rsp), %eax
	testl	%eax, %eax
	jle	.L9
	movslq	tail(%rip), %rdx
	addl	$1, %ebp
	leal	1(%rdx), %ecx
	movl	%eax, (%rbx,%rdx,4)
	movl	%ecx, tail(%rip)
	cmpl	%ebp, (%rsp)
	jg	.L6
.L11:
	movslq	tail(%rip), %rsi
	leaq	comp(%rip), %r12
	movl	$4, %edx
	movq	%rbx, %rdi
	movq	%r12, %rcx
	call	qsort@PLT
	movslq	4+tail(%rip), %rsi
	movl	$4, %edx
	movq	%r12, %rcx
	leaq	400000+q(%rip), %rdi
	call	qsort@PLT
	movl	tail(%rip), %edx
	movl	4+head(%rip), %edi
	testl	%edx, %edx
	jne	.L8
	movl	$1, tail(%rip)
	movslq	%edi, %rax
	addl	$1, %edi
	movl	400000(%rbx,%rax,4), %eax
	movl	%edi, 4+head(%rip)
	movl	%eax, q(%rip)
.L8:
	movl	4+tail(%rip), %eax
	movl	head(%rip), %esi
	testl	%eax, %eax
	jne	.L12
	movl	$1, 4+tail(%rip)
	movslq	%esi, %rax
	addl	$1, %esi
	movl	(%rbx,%rax,4), %eax
	movl	%esi, head(%rip)
	movl	%eax, 400000+q(%rip)
.L12:
	movl	tail(%rip), %r8d
	movl	%esi, %eax
	cmpl	%r8d, %esi
	jge	.L30
	movl	%r8d, %r9d
	subl	%esi, %r9d
	leal	-1(%r9), %edx
	cmpl	$2, %edx
	jbe	.L31
	movslq	%esi, %rax
	pxor	%xmm0, %xmm0
	leaq	(%rbx,%rax,4), %rdx
	movl	%r9d, %eax
	shrl	$2, %eax
	leal	-1(%rax), %ecx
	leaq	16(%rdx), %rax
	salq	$4, %rcx
	addq	%rax, %rcx
	jmp	.L15
	.p2align 4,,10
	.p2align 3
.L40:
	addq	$16, %rax
.L15:
	movdqu	(%rdx), %xmm1
	movq	%rax, %rdx
	paddd	%xmm1, %xmm0
	cmpq	%rcx, %rax
	jne	.L40
	movdqa	%xmm0, %xmm1
	movl	%r9d, %ecx
	psrldq	$8, %xmm1
	andl	$-4, %ecx
	paddd	%xmm1, %xmm0
	leal	(%rsi,%rcx), %eax
	movdqa	%xmm0, %xmm1
	psrldq	$4, %xmm1
	paddd	%xmm1, %xmm0
	movd	%xmm0, %edx
	cmpl	%ecx, %r9d
	je	.L13
.L14:
	movslq	%eax, %rcx
	addl	(%rbx,%rcx,4), %edx
	leal	1(%rax), %ecx
	cmpl	%ecx, %r8d
	jle	.L13
	movslq	%ecx, %rcx
	addl	$2, %eax
	addl	(%rbx,%rcx,4), %edx
	cmpl	%eax, %r8d
	jle	.L13
	cltq
	addl	(%rbx,%rax,4), %edx
.L13:
	movl	4+tail(%rip), %r8d
	movl	%edi, %eax
	cmpl	%r8d, %edi
	jge	.L18
	movl	%r8d, %r9d
	subl	%edi, %r9d
	leal	-1(%r9), %ecx
	cmpl	$2, %ecx
	jbe	.L19
	movslq	%edi, %rax
	pxor	%xmm0, %xmm0
	leaq	400000(%rbx,%rax,4), %rcx
	movl	%r9d, %eax
	shrl	$2, %eax
	leal	-1(%rax), %esi
	leaq	16(%rcx), %rax
	salq	$4, %rsi
	addq	%rax, %rsi
	jmp	.L20
	.p2align 4,,10
	.p2align 3
.L41:
	addq	$16, %rax
.L20:
	movdqu	(%rcx), %xmm1
	movq	%rax, %rcx
	psubd	%xmm1, %xmm0
	cmpq	%rax, %rsi
	jne	.L41
	movdqa	%xmm0, %xmm1
	movl	%r9d, %ecx
	psrldq	$8, %xmm1
	andl	$-4, %ecx
	paddd	%xmm1, %xmm0
	movdqa	%xmm0, %xmm1
	psrldq	$4, %xmm1
	paddd	%xmm1, %xmm0
	movd	%xmm0, %eax
	addl	%eax, %edx
	leal	(%rdi,%rcx), %eax
	cmpl	%r9d, %ecx
	je	.L18
.L19:
	movslq	%eax, %rcx
	subl	400000(%rbx,%rcx,4), %edx
	leal	1(%rax), %ecx
	cmpl	%r8d, %ecx
	jge	.L18
	movslq	%ecx, %rcx
	addl	$2, %eax
	subl	400000(%rbx,%rcx,4), %edx
	cmpl	%r8d, %eax
	jge	.L18
	cltq
	subl	400000(%rbx,%rax,4), %edx
.L18:
	leaq	.LC1(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movslq	head(%rip), %rax
	movl	tail(%rip), %edx
	subl	%eax, %edx
	cmpl	$1, %edx
	jle	.L23
	leaq	tail(%rip), %r12
	leaq	head(%rip), %rbp
	leaq	.LC2(%rip), %r13
	.p2align 4,,10
	.p2align 3
.L24:
	movl	(%rbx,%rax,4), %r15d
	leal	1(%rax), %edx
	movq	%r13, %rsi
	movl	$1, %edi
	movslq	4+head(%rip), %rax
	movl	%edx, 0(%rbp)
	movl	%r15d, %ecx
	movl	400000(%rbx,%rax,4), %r14d
	leal	1(%rax), %edx
	xorl	%eax, %eax
	movl	%edx, 4+head(%rip)
	movl	%r14d, %edx
	subl	%r15d, %r14d
	call	__printf_chk@PLT
	movslq	4+tail(%rip), %rax
	movl	(%r12), %edx
	leal	1(%rax), %ecx
	movl	%r14d, 400000(%rbx,%rax,4)
	movslq	0(%rbp), %rax
	movl	%ecx, 4+tail(%rip)
	subl	%eax, %edx
	cmpl	$1, %edx
	jg	.L24
.L25:
	movslq	4+head(%rip), %rdx
	subl	%edx, %ecx
	cmpl	$1, %ecx
	jle	.L26
	leaq	tail(%rip), %r12
	leaq	head(%rip), %rbp
	jmp	.L27
	.p2align 4,,10
	.p2align 3
.L42:
	movslq	0(%rbp), %rax
.L27:
	leal	1(%rax), %ecx
	movl	(%rbx,%rax,4), %r14d
	leal	1(%rdx), %eax
	movq	%r13, %rsi
	movl	400000(%rbx,%rdx,4), %r15d
	movl	%ecx, 0(%rbp)
	movl	$1, %edi
	movl	%r14d, %edx
	movl	%eax, 4+head(%rip)
	xorl	%eax, %eax
	movl	%r15d, %ecx
	subl	%r15d, %r14d
	call	__printf_chk@PLT
	movslq	(%r12), %rax
	leal	1(%rax), %edx
	movl	%r14d, (%rbx,%rax,4)
	movl	4+tail(%rip), %eax
	movl	%edx, (%r12)
	movslq	4+head(%rip), %rdx
	subl	%edx, %eax
	cmpl	$1, %eax
	jg	.L42
.L26:
	movslq	head(%rip), %rax
	movl	400000(%rbx,%rdx,4), %ecx
	movq	%r13, %rsi
	movl	$1, %edi
	movl	(%rbx,%rax,4), %edx
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	8(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L43
	addq	$24, %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
.L9:
	.cfi_restore_state
	movslq	4+tail(%rip), %rdx
	addl	$1, %ebp
	leal	1(%rdx), %ecx
	movl	%eax, 400000(%rbx,%rdx,4)
	movl	%ecx, 4+tail(%rip)
	cmpl	%ebp, (%rsp)
	jg	.L6
	jmp	.L11
.L30:
	xorl	%edx, %edx
	jmp	.L13
.L23:
	movl	4+tail(%rip), %ecx
	leaq	.LC2(%rip), %r13
	jmp	.L25
.L31:
	xorl	%edx, %edx
	jmp	.L14
.L43:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE42:
	.size	main, .-main
	.globl	tail
	.bss
	.align 8
	.type	tail, @object
	.size	tail, 8
tail:
	.zero	8
	.globl	head
	.align 8
	.type	head, @object
	.size	head, 8
head:
	.zero	8
	.globl	q
	.align 32
	.type	q, @object
	.size	q, 800000
q:
	.zero	800000
	.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	comp
	.type	comp, @function
comp:
.LFB41:
	.cfi_startproc
	endbr64
	movl	(%rdi), %edx
	movl	%edx, %eax
	subl	(%rsi), %eax
	imull	%edx, %eax
	ret
	.cfi_endproc
.LFE41:
	.size	comp, .-comp
	.p2align 4
	.globl	enq
	.type	enq, @function
enq:
.LFB39:
	.cfi_startproc
	endbr64
	movslq	%esi, %rsi
	leaq	tail(%rip), %rdx
	movslq	(%rdx,%rsi,4), %rax
	leal	1(%rax), %ecx
	movl	%ecx, (%rdx,%rsi,4)
	imulq	$100000, %rsi, %rsi
	addq	%rax, %rsi
	leaq	q(%rip), %rax
	movl	%edi, (%rax,%rsi,4)
	ret
	.cfi_endproc
.LFE39:
	.size	enq, .-enq
	.p2align 4
	.globl	deq
	.type	deq, @function
deq:
.LFB40:
	.cfi_startproc
	endbr64
	leaq	head(%rip), %rdx
	movslq	%edi, %rdi
	movslq	(%rdx,%rdi,4), %rax
	leal	1(%rax), %ecx
	movl	%ecx, (%rdx,%rdi,4)
	imulq	$100000, %rdi, %rdi
	addq	%rax, %rdi
	leaq	q(%rip), %rax
	movl	(%rax,%rdi,4), %eax
	ret
	.cfi_endproc
.LFE40:
	.size	deq, .-deq
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d"
.LC1:
	.string	"%d\n"
.LC2:
	.string	"%d %d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB42:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	leaq	.LC0(%rip), %r12
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	movq	%r12, %rdi
	xorl	%ebp, %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	leaq	q(%rip), %rbx
	subq	$24, %rsp
	.cfi_def_cfa_offset 80
	movq	%fs:40, %rax
	movq	%rax, 8(%rsp)
	xorl	%eax, %eax
	movq	%rsp, %rsi
	leaq	4(%rsp), %r13
	call	__isoc99_scanf@PLT
	movl	(%rsp), %ecx
	testl	%ecx, %ecx
	jle	.L11
	.p2align 4,,10
	.p2align 3
.L6:
	movq	%r13, %rsi
	movq	%r12, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	4(%rsp), %eax
	testl	%eax, %eax
	jle	.L9
	movslq	tail(%rip), %rdx
	addl	$1, %ebp
	leal	1(%rdx), %ecx
	movl	%eax, (%rbx,%rdx,4)
	movl	%ecx, tail(%rip)
	cmpl	%ebp, (%rsp)
	jg	.L6
.L11:
	movslq	tail(%rip), %rsi
	leaq	comp(%rip), %r12
	movl	$4, %edx
	movq	%rbx, %rdi
	movq	%r12, %rcx
	call	qsort@PLT
	movslq	4+tail(%rip), %rsi
	movl	$4, %edx
	movq	%r12, %rcx
	leaq	400000+q(%rip), %rdi
	call	qsort@PLT
	movl	tail(%rip), %edx
	movl	4+head(%rip), %edi
	testl	%edx, %edx
	jne	.L8
	movl	$1, tail(%rip)
	movslq	%edi, %rax
	addl	$1, %edi
	movl	400000(%rbx,%rax,4), %eax
	movl	%edi, 4+head(%rip)
	movl	%eax, q(%rip)
.L8:
	movl	4+tail(%rip), %eax
	movl	head(%rip), %esi
	testl	%eax, %eax
	jne	.L12
	movl	$1, 4+tail(%rip)
	movslq	%esi, %rax
	addl	$1, %esi
	movl	(%rbx,%rax,4), %eax
	movl	%esi, head(%rip)
	movl	%eax, 400000+q(%rip)
.L12:
	movl	tail(%rip), %r8d
	movl	%esi, %eax
	cmpl	%r8d, %esi
	jge	.L30
	movl	%r8d, %r9d
	subl	%esi, %r9d
	leal	-1(%r9), %edx
	cmpl	$2, %edx
	jbe	.L31
	movslq	%esi, %rax
	pxor	%xmm0, %xmm0
	leaq	(%rbx,%rax,4), %rdx
	movl	%r9d, %eax
	shrl	$2, %eax
	leal	-1(%rax), %ecx
	leaq	16(%rdx), %rax
	salq	$4, %rcx
	addq	%rax, %rcx
	jmp	.L15
	.p2align 4,,10
	.p2align 3
.L40:
	addq	$16, %rax
.L15:
	movdqu	(%rdx), %xmm1
	movq	%rax, %rdx
	paddd	%xmm1, %xmm0
	cmpq	%rcx, %rax
	jne	.L40
	movdqa	%xmm0, %xmm1
	movl	%r9d, %ecx
	psrldq	$8, %xmm1
	andl	$-4, %ecx
	paddd	%xmm1, %xmm0
	leal	(%rsi,%rcx), %eax
	movdqa	%xmm0, %xmm1
	psrldq	$4, %xmm1
	paddd	%xmm1, %xmm0
	movd	%xmm0, %edx
	cmpl	%ecx, %r9d
	je	.L13
.L14:
	movslq	%eax, %rcx
	addl	(%rbx,%rcx,4), %edx
	leal	1(%rax), %ecx
	cmpl	%ecx, %r8d
	jle	.L13
	movslq	%ecx, %rcx
	addl	$2, %eax
	addl	(%rbx,%rcx,4), %edx
	cmpl	%eax, %r8d
	jle	.L13
	cltq
	addl	(%rbx,%rax,4), %edx
.L13:
	movl	4+tail(%rip), %r8d
	movl	%edi, %eax
	cmpl	%r8d, %edi
	jge	.L18
	movl	%r8d, %r9d
	subl	%edi, %r9d
	leal	-1(%r9), %ecx
	cmpl	$2, %ecx
	jbe	.L19
	movslq	%edi, %rax
	pxor	%xmm0, %xmm0
	leaq	400000(%rbx,%rax,4), %rcx
	movl	%r9d, %eax
	shrl	$2, %eax
	leal	-1(%rax), %esi
	leaq	16(%rcx), %rax
	salq	$4, %rsi
	addq	%rax, %rsi
	jmp	.L20
	.p2align 4,,10
	.p2align 3
.L41:
	addq	$16, %rax
.L20:
	movdqu	(%rcx), %xmm1
	movq	%rax, %rcx
	psubd	%xmm1, %xmm0
	cmpq	%rax, %rsi
	jne	.L41
	movdqa	%xmm0, %xmm1
	movl	%r9d, %ecx
	psrldq	$8, %xmm1
	andl	$-4, %ecx
	paddd	%xmm1, %xmm0
	movdqa	%xmm0, %xmm1
	psrldq	$4, %xmm1
	paddd	%xmm1, %xmm0
	movd	%xmm0, %eax
	addl	%eax, %edx
	leal	(%rdi,%rcx), %eax
	cmpl	%r9d, %ecx
	je	.L18
.L19:
	movslq	%eax, %rcx
	subl	400000(%rbx,%rcx,4), %edx
	leal	1(%rax), %ecx
	cmpl	%r8d, %ecx
	jge	.L18
	movslq	%ecx, %rcx
	addl	$2, %eax
	subl	400000(%rbx,%rcx,4), %edx
	cmpl	%r8d, %eax
	jge	.L18
	cltq
	subl	400000(%rbx,%rax,4), %edx
.L18:
	leaq	.LC1(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movslq	head(%rip), %rax
	movl	tail(%rip), %edx
	subl	%eax, %edx
	cmpl	$1, %edx
	jle	.L23
	leaq	tail(%rip), %r12
	leaq	head(%rip), %rbp
	leaq	.LC2(%rip), %r13
	.p2align 4,,10
	.p2align 3
.L24:
	movl	(%rbx,%rax,4), %r15d
	leal	1(%rax), %edx
	movq	%r13, %rsi
	movl	$1, %edi
	movslq	4+head(%rip), %rax
	movl	%edx, 0(%rbp)
	movl	%r15d, %ecx
	movl	400000(%rbx,%rax,4), %r14d
	leal	1(%rax), %edx
	xorl	%eax, %eax
	movl	%edx, 4+head(%rip)
	movl	%r14d, %edx
	subl	%r15d, %r14d
	call	__printf_chk@PLT
	movslq	4+tail(%rip), %rax
	movl	(%r12), %edx
	leal	1(%rax), %ecx
	movl	%r14d, 400000(%rbx,%rax,4)
	movslq	0(%rbp), %rax
	movl	%ecx, 4+tail(%rip)
	subl	%eax, %edx
	cmpl	$1, %edx
	jg	.L24
.L25:
	movslq	4+head(%rip), %rdx
	subl	%edx, %ecx
	cmpl	$1, %ecx
	jle	.L26
	leaq	tail(%rip), %r12
	leaq	head(%rip), %rbp
	jmp	.L27
	.p2align 4,,10
	.p2align 3
.L42:
	movslq	0(%rbp), %rax
.L27:
	leal	1(%rax), %ecx
	movl	(%rbx,%rax,4), %r14d
	leal	1(%rdx), %eax
	movq	%r13, %rsi
	movl	400000(%rbx,%rdx,4), %r15d
	movl	%ecx, 0(%rbp)
	movl	$1, %edi
	movl	%r14d, %edx
	movl	%eax, 4+head(%rip)
	xorl	%eax, %eax
	movl	%r15d, %ecx
	subl	%r15d, %r14d
	call	__printf_chk@PLT
	movslq	(%r12), %rax
	leal	1(%rax), %edx
	movl	%r14d, (%rbx,%rax,4)
	movl	4+tail(%rip), %eax
	movl	%edx, (%r12)
	movslq	4+head(%rip), %rdx
	subl	%edx, %eax
	cmpl	$1, %eax
	jg	.L42
.L26:
	movslq	head(%rip), %rax
	movl	400000(%rbx,%rdx,4), %ecx
	movq	%r13, %rsi
	movl	$1, %edi
	movl	(%rbx,%rax,4), %edx
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	8(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L43
	addq	$24, %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
.L9:
	.cfi_restore_state
	movslq	4+tail(%rip), %rdx
	addl	$1, %ebp
	leal	1(%rdx), %ecx
	movl	%eax, 400000(%rbx,%rdx,4)
	movl	%ecx, 4+tail(%rip)
	cmpl	%ebp, (%rsp)
	jg	.L6
	jmp	.L11
.L30:
	xorl	%edx, %edx
	jmp	.L13
.L23:
	movl	4+tail(%rip), %ecx
	leaq	.LC2(%rip), %r13
	jmp	.L25
.L31:
	xorl	%edx, %edx
	jmp	.L14
.L43:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE42:
	.size	main, .-main
	.globl	tail
	.bss
	.align 8
	.type	tail, @object
	.size	tail, 8
tail:
	.zero	8
	.globl	head
	.align 8
	.type	head, @object
	.size	head, 8
head:
	.zero	8
	.globl	q
	.align 32
	.type	q, @object
	.size	q, 800000
q:
	.zero	800000
	.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>
#define df 0
#define MAX 100000

int q[2][MAX];
int head[2]={},tail[2]={};
void enq(int a,int t);
int deq(int t);
void enq(int a,int t){
  q[t][tail[t]++]=a;
}
int deq(int t){
  return q[t][head[t]++];
}
int comp(const void *a,const void *b){
  int x=*((int*)a), y=*((int*)b);
  return (x-y)*x;
}

int main(){
  int n;
  scanf("%d",&n);
  int i;  
  for(i=0;i<n;i++){
    int a;
    scanf("%d",&a);
    if(a>0) enq(a,0);
    else enq(a,1);
  }
  qsort(q[0],tail[0],sizeof(int),comp);
  qsort(q[1],tail[1],sizeof(int),comp);
  if(tail[0]==0){
    enq(deq(1),0);
  }
  if(tail[1]==0){
    enq(deq(0),1);
  }
  if(df){
    int t;
    for(t=0;t<2;t++){
    printf("q[%d]:[",t);
      for(i=head[t];i<tail[t];i++)printf(" %d",q[t][i]);
      printf(" ]\n");
    }
  }
  int s=0;
  for(i=head[0];i<tail[0];i++){
    s+=q[0][i];
  }
  for(i=head[1];i<tail[1];i++){
    s-=q[1][i];
  }
  printf("%d\n",s);
  while(tail[0]-head[0]>1){
    int a=deq(0),b=deq(1);
    printf("%d %d\n",b,a);
    enq(b-a,1);
  if(df){
    int t;
    for(t=0;t<2;t++){
    printf("q[%d]:[",t);
      for(i=head[t];i<tail[t];i++)printf(" %d",q[t][i]);
      printf(" ]\n");
    }
  }
  }
  while(tail[1]-head[1]>1){
    int a=deq(0),b=deq(1);
    printf("%d %d\n",a,b);
    enq(a-b,0);
    if(df){
      int t;
      for(t=0;t<2;t++){
	printf("q[%d]:[",t);
	for(i=head[t];i<tail[t];i++)printf(" %d",q[t][i]);
	printf(" ]\n");
      }
    }
  }
  printf("%d %d\n",q[0][head[0]],q[1][head[1]]);
}




3
0 1 1
 3
2 -1 2
 3
2 0 2
 3
2 0 1
 3
2 1 1
 3
2 1 2
 3
1 1 -1
 3
2 2 2
 3
3 2 2
 3
3 1 0

2
0 1
1 -1
 5
-1 2
2 -3
 4
0 2
2 -2
 3
0 1
2 -1
 2
1 1
2 0
 3
1 2
2 -1
 3
-1 1
1 -2
 2
2 2
2 0
 3
2 2
3 0
 4
0 1
3 -1

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>
#define df 0
#define MAX 100000

int q[2][MAX];
int head[2]={},tail[2]={};
void enq(int a,int t);
int deq(int t);
void enq(int a,int t){
  q[t][tail[t]++]=a;
}
int deq(int t){
  return q[t][head[t]++];
}
int comp(const void *a,const void *b){
  int x=*((int*)a), y=*((int*)b);
  return (x-y)*x;
}

int main(){
  int n;
  scanf("%d",&n);
  int i;  
  for(i=0;i<n;i++){
    int a;
    scanf("%d",&a);
    if(a>0) enq(a,0);
    else enq(a,1);
  }
  qsort(q[0],tail[0],sizeof(int),comp);
  qsort(q[1],tail[1],sizeof(int),comp);
  if(tail[0]==0){
    enq(deq(1),0);
  }
  if(tail[1]==0){
    enq(deq(0),1);
  }
  if(df){
    int t;
    for(t=0;t<2;t++){
    printf("q[%d]:[",t);
      for(i=head[t];i<tail[t];i++)printf(" %d",q[t][i]);
      printf(" ]\n");
    }
  }
  int s=0;
  for(i=head[0];i<tail[0];i++){
    s+=q[0][i];
  }
  for(i=head[1];i<tail[1];i++){
    s-=q[1][i];
  }
  printf("%d\n",s);
  while(tail[0]-head[0]>1){
    int a=deq(0),b=deq(1);
    printf("%d %d\n",b,a);
    enq(b-a,1);
  if(df){
    int t;
    for(t=0;t<2;t++){
    printf("q[%d]:[",t);
      for(i=head[t];i<tail[t];i++)printf(" %d",q[t][i]);
      printf(" ]\n");
    }
  }
  }
  while(tail[1]-head[1]>1){
    int a=deq(0),b=deq(1);
    printf("%d %d\n",a,b);
    enq(a-b,0);
    if(df){
      int t;
      for(t=0;t<2;t++){
	printf("q[%d]:[",t);
	for(i=head[t];i<tail[t];i++)printf(" %d",q[t][i]);
	printf(" ]\n");
      }
    }
  }
  printf("%d %d\n",q[0][head[0]],q[1][head[1]]);
}



```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	q
	.bss
	.align 32
	.type	q, @object
	.size	q, 800000
q:
	.zero	800000
	.globl	head
	.align 8
	.type	head, @object
	.size	head, 8
head:
	.zero	8
	.globl	tail
	.align 8
	.type	tail, @object
	.size	tail, 8
tail:
	.zero	8
	.text
	.globl	enq
	.type	enq, @function
enq:
.LFB6:
	.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), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	tail(%rip), %rax
	movl	(%rdx,%rax), %eax
	leal	1(%rax), %edx
	movl	-8(%rbp), %ecx
	movslq	%ecx, %rcx
	leaq	0(,%rcx,4), %rsi
	leaq	tail(%rip), %rcx
	movl	%edx, (%rsi,%rcx)
	movslq	%eax, %rdx
	movl	-8(%rbp), %eax
	cltq
	imulq	$100000, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rcx
	leaq	q(%rip), %rdx
	movl	-4(%rbp), %eax
	movl	%eax, (%rcx,%rdx)
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	enq, .-enq
	.globl	deq
	.type	deq, @function
deq:
.LFB7:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	%edi, -4(%rbp)
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	head(%rip), %rax
	movl	(%rdx,%rax), %eax
	leal	1(%rax), %edx
	movl	-4(%rbp), %ecx
	movslq	%ecx, %rcx
	leaq	0(,%rcx,4), %rsi
	leaq	head(%rip), %rcx
	movl	%edx, (%rsi,%rcx)
	movslq	%eax, %rdx
	movl	-4(%rbp), %eax
	cltq
	imulq	$100000, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	q(%rip), %rax
	movl	(%rdx,%rax), %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.size	deq, .-deq
	.globl	comp
	.type	comp, @function
comp:
.LFB8:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movq	%rdi, -24(%rbp)
	movq	%rsi, -32(%rbp)
	movq	-24(%rbp), %rax
	movl	(%rax), %eax
	movl	%eax, -8(%rbp)
	movq	-32(%rbp), %rax
	movl	(%rax), %eax
	movl	%eax, -4(%rbp)
	movl	-8(%rbp), %eax
	subl	-4(%rbp), %eax
	imull	-8(%rbp), %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE8:
	.size	comp, .-comp
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%d\n"
.LC2:
	.string	"%d %d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB9:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$48, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-40(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -28(%rbp)
	jmp	.L7
.L10:
	leaq	-36(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-36(%rbp), %eax
	testl	%eax, %eax
	jle	.L8
	movl	-36(%rbp), %eax
	movl	$0, %esi
	movl	%eax, %edi
	call	enq
	jmp	.L9
.L8:
	movl	-36(%rbp), %eax
	movl	$1, %esi
	movl	%eax, %edi
	call	enq
.L9:
	addl	$1, -28(%rbp)
.L7:
	movl	-40(%rbp), %eax
	cmpl	%eax, -28(%rbp)
	jl	.L10
	movl	tail(%rip), %eax
	cltq
	leaq	comp(%rip), %rdx
	movq	%rdx, %rcx
	movl	$4, %edx
	movq	%rax, %rsi
	leaq	q(%rip), %rax
	movq	%rax, %rdi
	call	qsort@PLT
	movl	4+tail(%rip), %eax
	cltq
	leaq	comp(%rip), %rdx
	movq	%rdx, %rcx
	movl	$4, %edx
	movq	%rax, %rsi
	leaq	400000+q(%rip), %rax
	movq	%rax, %rdi
	call	qsort@PLT
	movl	tail(%rip), %eax
	testl	%eax, %eax
	jne	.L11
	movl	$1, %edi
	call	deq
	movl	$0, %esi
	movl	%eax, %edi
	call	enq
.L11:
	movl	4+tail(%rip), %eax
	testl	%eax, %eax
	jne	.L12
	movl	$0, %edi
	call	deq
	movl	$1, %esi
	movl	%eax, %edi
	call	enq
.L12:
	movl	$0, -32(%rbp)
	movl	head(%rip), %eax
	movl	%eax, -28(%rbp)
	jmp	.L13
.L14:
	movl	-28(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	q(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	%eax, -32(%rbp)
	addl	$1, -28(%rbp)
.L13:
	movl	tail(%rip), %eax
	cmpl	%eax, -28(%rbp)
	jl	.L14
	movl	4+head(%rip), %eax
	movl	%eax, -28(%rbp)
	jmp	.L15
.L16:
	movl	-28(%rbp), %eax
	cltq
	addq	$100000, %rax
	leaq	0(,%rax,4), %rdx
	leaq	q(%rip), %rax
	movl	(%rdx,%rax), %eax
	subl	%eax, -32(%rbp)
	addl	$1, -28(%rbp)
.L15:
	movl	4+tail(%rip), %eax
	cmpl	%eax, -28(%rbp)
	jl	.L16
	movl	-32(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L17
.L18:
	movl	$0, %edi
	call	deq
	movl	%eax, -16(%rbp)
	movl	$1, %edi
	call	deq
	movl	%eax, -12(%rbp)
	movl	-16(%rbp), %edx
	movl	-12(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	-12(%rbp), %eax
	subl	-16(%rbp), %eax
	movl	$1, %esi
	movl	%eax, %edi
	call	enq
.L17:
	movl	tail(%rip), %eax
	movl	head(%rip), %edx
	subl	%edx, %eax
	cmpl	$1, %eax
	jg	.L18
	jmp	.L19
.L20:
	movl	$0, %edi
	call	deq
	movl	%eax, -24(%rbp)
	movl	$1, %edi
	call	deq
	movl	%eax, -20(%rbp)
	movl	-20(%rbp), %edx
	movl	-24(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	-24(%rbp), %eax
	subl	-20(%rbp), %eax
	movl	$0, %esi
	movl	%eax, %edi
	call	enq
.L19:
	movl	4+tail(%rip), %eax
	movl	4+head(%rip), %edx
	subl	%edx, %eax
	cmpl	$1, %eax
	jg	.L20
	movl	4+head(%rip), %eax
	cltq
	addq	$100000, %rax
	leaq	0(,%rax,4), %rdx
	leaq	q(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	head(%rip), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	q(%rip), %rax
	movl	(%rcx,%rax), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L22
	call	__stack_chk_fail@PLT
.L22:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE9:
	.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	q
	.bss
	.align 32
	.type	q, @object
	.size	q, 800000
q:
	.zero	800000
	.globl	head
	.align 8
	.type	head, @object
	.size	head, 8
head:
	.zero	8
	.globl	tail
	.align 8
	.type	tail, @object
	.size	tail, 8
tail:
	.zero	8
	.text
	.globl	enq
	.type	enq, @function
enq:
.LFB6:
	.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), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	tail(%rip), %rax
	movl	(%rdx,%rax), %eax
	leal	1(%rax), %edx
	movl	-8(%rbp), %ecx
	movslq	%ecx, %rcx
	leaq	0(,%rcx,4), %rsi
	leaq	tail(%rip), %rcx
	movl	%edx, (%rsi,%rcx)
	movslq	%eax, %rdx
	movl	-8(%rbp), %eax
	cltq
	imulq	$100000, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rcx
	leaq	q(%rip), %rdx
	movl	-4(%rbp), %eax
	movl	%eax, (%rcx,%rdx)
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	enq, .-enq
	.globl	deq
	.type	deq, @function
deq:
.LFB7:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	%edi, -4(%rbp)
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	head(%rip), %rax
	movl	(%rdx,%rax), %eax
	leal	1(%rax), %edx
	movl	-4(%rbp), %ecx
	movslq	%ecx, %rcx
	leaq	0(,%rcx,4), %rsi
	leaq	head(%rip), %rcx
	movl	%edx, (%rsi,%rcx)
	movslq	%eax, %rdx
	movl	-4(%rbp), %eax
	cltq
	imulq	$100000, %rax, %rax
	addq	%rdx, %rax
	leaq	0(,%rax,4), %rdx
	leaq	q(%rip), %rax
	movl	(%rdx,%rax), %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.size	deq, .-deq
	.globl	comp
	.type	comp, @function
comp:
.LFB8:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movq	%rdi, -24(%rbp)
	movq	%rsi, -32(%rbp)
	movq	-24(%rbp), %rax
	movl	(%rax), %eax
	movl	%eax, -8(%rbp)
	movq	-32(%rbp), %rax
	movl	(%rax), %eax
	movl	%eax, -4(%rbp)
	movl	-8(%rbp), %eax
	subl	-4(%rbp), %eax
	imull	-8(%rbp), %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE8:
	.size	comp, .-comp
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%d\n"
.LC2:
	.string	"%d %d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB9:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$48, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-40(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -28(%rbp)
	jmp	.L7
.L10:
	leaq	-36(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-36(%rbp), %eax
	testl	%eax, %eax
	jle	.L8
	movl	-36(%rbp), %eax
	movl	$0, %esi
	movl	%eax, %edi
	call	enq
	jmp	.L9
.L8:
	movl	-36(%rbp), %eax
	movl	$1, %esi
	movl	%eax, %edi
	call	enq
.L9:
	addl	$1, -28(%rbp)
.L7:
	movl	-40(%rbp), %eax
	cmpl	%eax, -28(%rbp)
	jl	.L10
	movl	tail(%rip), %eax
	cltq
	leaq	comp(%rip), %rdx
	movq	%rdx, %rcx
	movl	$4, %edx
	movq	%rax, %rsi
	leaq	q(%rip), %rax
	movq	%rax, %rdi
	call	qsort@PLT
	movl	4+tail(%rip), %eax
	cltq
	leaq	comp(%rip), %rdx
	movq	%rdx, %rcx
	movl	$4, %edx
	movq	%rax, %rsi
	leaq	400000+q(%rip), %rax
	movq	%rax, %rdi
	call	qsort@PLT
	movl	tail(%rip), %eax
	testl	%eax, %eax
	jne	.L11
	movl	$1, %edi
	call	deq
	movl	$0, %esi
	movl	%eax, %edi
	call	enq
.L11:
	movl	4+tail(%rip), %eax
	testl	%eax, %eax
	jne	.L12
	movl	$0, %edi
	call	deq
	movl	$1, %esi
	movl	%eax, %edi
	call	enq
.L12:
	movl	$0, -32(%rbp)
	movl	head(%rip), %eax
	movl	%eax, -28(%rbp)
	jmp	.L13
.L14:
	movl	-28(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	q(%rip), %rax
	movl	(%rdx,%rax), %eax
	addl	%eax, -32(%rbp)
	addl	$1, -28(%rbp)
.L13:
	movl	tail(%rip), %eax
	cmpl	%eax, -28(%rbp)
	jl	.L14
	movl	4+head(%rip), %eax
	movl	%eax, -28(%rbp)
	jmp	.L15
.L16:
	movl	-28(%rbp), %eax
	cltq
	addq	$100000, %rax
	leaq	0(,%rax,4), %rdx
	leaq	q(%rip), %rax
	movl	(%rdx,%rax), %eax
	subl	%eax, -32(%rbp)
	addl	$1, -28(%rbp)
.L15:
	movl	4+tail(%rip), %eax
	cmpl	%eax, -28(%rbp)
	jl	.L16
	movl	-32(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L17
.L18:
	movl	$0, %edi
	call	deq
	movl	%eax, -16(%rbp)
	movl	$1, %edi
	call	deq
	movl	%eax, -12(%rbp)
	movl	-16(%rbp), %edx
	movl	-12(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	-12(%rbp), %eax
	subl	-16(%rbp), %eax
	movl	$1, %esi
	movl	%eax, %edi
	call	enq
.L17:
	movl	tail(%rip), %eax
	movl	head(%rip), %edx
	subl	%edx, %eax
	cmpl	$1, %eax
	jg	.L18
	jmp	.L19
.L20:
	movl	$0, %edi
	call	deq
	movl	%eax, -24(%rbp)
	movl	$1, %edi
	call	deq
	movl	%eax, -20(%rbp)
	movl	-20(%rbp), %edx
	movl	-24(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	-24(%rbp), %eax
	subl	-20(%rbp), %eax
	movl	$0, %esi
	movl	%eax, %edi
	call	enq
.L19:
	movl	4+tail(%rip), %eax
	movl	4+head(%rip), %edx
	subl	%edx, %eax
	cmpl	$1, %eax
	jg	.L20
	movl	4+head(%rip), %eax
	cltq
	addq	$100000, %rax
	leaq	0(,%rax,4), %rdx
	leaq	q(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	head(%rip), %eax
	cltq
	leaq	0(,%rax,4), %rcx
	leaq	q(%rip), %rax
	movl	(%rcx,%rax), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L22
	call	__stack_chk_fail@PLT
.L22:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE9:
	.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:
