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>

struct TQueue{
  int x,y,dep;
  struct TQueue* next;
};

void allfree(struct TQueue* q){
  struct TQueue* r[2];
  r[0]=q;
  if(q==0)return;
  r[1]=q->next;
  while(r[1]){
    free(r[0]);
    r[0]=r[1];
    r[1]=r[1]->next;
  }
  free(r[0]);
}

struct TQueue* push(struct TQueue* ed,int y,int x,int d){
  if(ed==0){
    return 0;
  }
  ed->next=(struct TQueue*)malloc(sizeof(struct TQueue));
  ed->next->next=0;
  ed->next->dep=d;
  ed->next->x=x;
  ed->next->y=y;
  return ed->next;
}

struct TQueue* Queue(int y,int x,int d){
  struct TQueue* ret;
  ret=(struct TQueue*)malloc(sizeof(struct TQueue));
  ret->next=0;
  ret->x=x;
  ret->y=y;
  ret->dep=d;
  return ret;
}


struct TQueue* delhead(struct TQueue* st){
  struct TQueue* ret;
  if(!st)return 0;
  ret=st->next;
  free(st);
  return ret;
}




int main(){
  int w,h,n;
  int i,j,k;
  char* s;
  int mp[1000][1000];
  int ts[1002][1002];
  int ret,ls,pt;
  int gy[10],gx[10];
  struct TQueue *st,*ed;
  s=(char*)malloc(sizeof(char)*1001);

  gets(s);
  sscanf(s,"%d %d %d",&h,&w,&n);

  for(i=0;i<h;i++){
    gets(s);
    for(j=0;j<w;j++){
      mp[i][j]=s[j]=='X'?1:0;
      if(s[j]>='1'&&s[j]<='9'){
        gy[s[j]-'0']=i+1;
        gx[s[j]-'0']=j+1;
      }
      if(s[j]=='S'){
        gy[0]=i+1;
        gx[0]=j+1;
      }
    }
  }
  for(i=0;i<h+2;i++){
    ts[i][0]=1;
    ts[i][w+1]=1;
  }
  for(j=0;j<w+2;j++){
    ts[0][j]=1;
    ts[h+1][j]=1;
  }
  ret=0;
  for(k=0;k<n;k++){
    st=Queue(gy[k],gx[k],ret);
    ed=st;
    for(i=0;i<h;i++){
      for(j=0;j<w;j++){
        ts[i+1][j+1]=mp[i][j];
      }
    }

    while(st){
      if(((st->y+1==gy[k+1]||st->y-1==gy[k+1])&&st->x==gx[k+1])
        ||((st->x+1==gx[k+1]||st->x-1==gx[k+1])&&st->y==gy[k+1])){
        break;
      }
      if(ts[st->y+1][st->x]==0){
        ts[st->y+1][st->x]=1;
        ed=push(ed,st->y+1,st->x,st->dep+1);
      }
      if(!ts[st->y-1][st->x]){
        ts[st->y-1][st->x]=1;
        ed=push(ed,st->y-1,st->x,st->dep+1);   
      }
      if(!ts[st->y][st->x-1]){
        ts[st->y][st->x-1]=1;
        ed=push(ed,st->y,st->x-1,st->dep+1);
      }
      if(!ts[st->y][st->x+1]){
        ts[st->y][st->x+1]=1;
        ed=push(ed,st->y,st->x+1,st->dep+1);
      }
      st=delhead(st);
    }
    if(st){
      ret=st->dep+1;
      allfree(st);
    }else{
      printf("Incorrect Data\n");
      return 0;
    }
  }

  printf("%d\n",ret);
  return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	allfree
	.type	allfree, @function
allfree:
.LFB6:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$48, %rsp
	movq	%rdi, -40(%rbp)
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movq	-40(%rbp), %rax
	movq	%rax, -32(%rbp)
	cmpq	$0, -40(%rbp)
	je	.L7
	movq	-40(%rbp), %rax
	movq	16(%rax), %rax
	movq	%rax, -24(%rbp)
	jmp	.L4
.L5:
	movq	-32(%rbp), %rax
	movq	%rax, %rdi
	call	free@PLT
	movq	-24(%rbp), %rax
	movq	%rax, -32(%rbp)
	movq	-24(%rbp), %rax
	movq	16(%rax), %rax
	movq	%rax, -24(%rbp)
.L4:
	movq	-24(%rbp), %rax
	testq	%rax, %rax
	jne	.L5
	movq	-32(%rbp), %rax
	movq	%rax, %rdi
	call	free@PLT
	jmp	.L1
.L7:
	nop
.L1:
	movq	-8(%rbp), %rax
	subq	%fs:40, %rax
	je	.L6
	call	__stack_chk_fail@PLT
.L6:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	allfree, .-allfree
	.globl	push
	.type	push, @function
push:
.LFB7:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$32, %rsp
	movq	%rdi, -8(%rbp)
	movl	%esi, -12(%rbp)
	movl	%edx, -16(%rbp)
	movl	%ecx, -20(%rbp)
	cmpq	$0, -8(%rbp)
	jne	.L9
	movl	$0, %eax
	jmp	.L10
.L9:
	movl	$24, %edi
	call	malloc@PLT
	movq	%rax, %rdx
	movq	-8(%rbp), %rax
	movq	%rdx, 16(%rax)
	movq	-8(%rbp), %rax
	movq	16(%rax), %rax
	movq	$0, 16(%rax)
	movq	-8(%rbp), %rax
	movq	16(%rax), %rax
	movl	-20(%rbp), %edx
	movl	%edx, 8(%rax)
	movq	-8(%rbp), %rax
	movq	16(%rax), %rax
	movl	-16(%rbp), %edx
	movl	%edx, (%rax)
	movq	-8(%rbp), %rax
	movq	16(%rax), %rax
	movl	-12(%rbp), %edx
	movl	%edx, 4(%rax)
	movq	-8(%rbp), %rax
	movq	16(%rax), %rax
.L10:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.size	push, .-push
	.globl	Queue
	.type	Queue, @function
Queue:
.LFB8:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$32, %rsp
	movl	%edi, -20(%rbp)
	movl	%esi, -24(%rbp)
	movl	%edx, -28(%rbp)
	movl	$24, %edi
	call	malloc@PLT
	movq	%rax, -8(%rbp)
	movq	-8(%rbp), %rax
	movq	$0, 16(%rax)
	movq	-8(%rbp), %rax
	movl	-24(%rbp), %edx
	movl	%edx, (%rax)
	movq	-8(%rbp), %rax
	movl	-20(%rbp), %edx
	movl	%edx, 4(%rax)
	movq	-8(%rbp), %rax
	movl	-28(%rbp), %edx
	movl	%edx, 8(%rax)
	movq	-8(%rbp), %rax
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE8:
	.size	Queue, .-Queue
	.globl	delhead
	.type	delhead, @function
delhead:
.LFB9:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$32, %rsp
	movq	%rdi, -24(%rbp)
	cmpq	$0, -24(%rbp)
	jne	.L14
	movl	$0, %eax
	jmp	.L15
.L14:
	movq	-24(%rbp), %rax
	movq	16(%rax), %rax
	movq	%rax, -8(%rbp)
	movq	-24(%rbp), %rax
	movq	%rax, %rdi
	call	free@PLT
	movq	-8(%rbp), %rax
.L15:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE9:
	.size	delhead, .-delhead
	.section	.rodata
.LC0:
	.string	"%d %d %d"
.LC1:
	.string	"Incorrect Data"
.LC2:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB10:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	leaq	-8015872(%rsp), %r11
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	subq	$320, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	$1001, %edi
	call	malloc@PLT
	movq	%rax, -8016136(%rbp)
	movq	-8016136(%rbp), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	gets@PLT
	leaq	-8016172(%rbp), %rsi
	leaq	-8016180(%rbp), %rcx
	leaq	-8016176(%rbp), %rdx
	movq	-8016136(%rbp), %rax
	movq	%rsi, %r8
	leaq	.LC0(%rip), %rsi
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_sscanf@PLT
	movl	$0, -8016168(%rbp)
	jmp	.L17
.L22:
	movq	-8016136(%rbp), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	gets@PLT
	movl	$0, -8016164(%rbp)
	jmp	.L18
.L21:
	movl	-8016164(%rbp), %eax
	movslq	%eax, %rdx
	movq	-8016136(%rbp), %rax
	addq	%rdx, %rax
	movzbl	(%rax), %eax
	cmpb	$88, %al
	sete	%al
	movzbl	%al, %eax
	movl	-8016164(%rbp), %edx
	movslq	%edx, %rcx
	movl	-8016168(%rbp), %edx
	movslq	%edx, %rdx
	imulq	$1000, %rdx, %rdx
	addq	%rcx, %rdx
	movl	%eax, -8016032(%rbp,%rdx,4)
	movl	-8016164(%rbp), %eax
	movslq	%eax, %rdx
	movq	-8016136(%rbp), %rax
	addq	%rdx, %rax
	movzbl	(%rax), %eax
	cmpb	$48, %al
	jle	.L19
	movl	-8016164(%rbp), %eax
	movslq	%eax, %rdx
	movq	-8016136(%rbp), %rax
	addq	%rdx, %rax
	movzbl	(%rax), %eax
	cmpb	$57, %al
	jg	.L19
	movl	-8016164(%rbp), %eax
	movslq	%eax, %rdx
	movq	-8016136(%rbp), %rax
	addq	%rdx, %rax
	movzbl	(%rax), %eax
	movsbl	%al, %eax
	leal	-48(%rax), %ecx
	movl	-8016168(%rbp), %eax
	leal	1(%rax), %edx
	movslq	%ecx, %rax
	movl	%edx, -8016128(%rbp,%rax,4)
	movl	-8016164(%rbp), %eax
	movslq	%eax, %rdx
	movq	-8016136(%rbp), %rax
	addq	%rdx, %rax
	movzbl	(%rax), %eax
	movsbl	%al, %eax
	leal	-48(%rax), %ecx
	movl	-8016164(%rbp), %eax
	leal	1(%rax), %edx
	movslq	%ecx, %rax
	movl	%edx, -8016080(%rbp,%rax,4)
.L19:
	movl	-8016164(%rbp), %eax
	movslq	%eax, %rdx
	movq	-8016136(%rbp), %rax
	addq	%rdx, %rax
	movzbl	(%rax), %eax
	cmpb	$83, %al
	jne	.L20
	movl	-8016168(%rbp), %eax
	addl	$1, %eax
	movl	%eax, -8016128(%rbp)
	movl	-8016164(%rbp), %eax
	addl	$1, %eax
	movl	%eax, -8016080(%rbp)
.L20:
	addl	$1, -8016164(%rbp)
.L18:
	movl	-8016180(%rbp), %eax
	cmpl	%eax, -8016164(%rbp)
	jl	.L21
	addl	$1, -8016168(%rbp)
.L17:
	movl	-8016176(%rbp), %eax
	cmpl	%eax, -8016168(%rbp)
	jl	.L22
	movl	$0, -8016168(%rbp)
	jmp	.L23
.L24:
	movl	-8016168(%rbp), %eax
	cltq
	imulq	$4008, %rax, %rax
	addq	%rbp, %rax
	subq	$4016032, %rax
	movl	$1, (%rax)
	movl	-8016180(%rbp), %eax
	addl	$1, %eax
	movslq	%eax, %rdx
	movl	-8016168(%rbp), %eax
	cltq
	imulq	$1002, %rax, %rax
	addq	%rdx, %rax
	movl	$1, -4016032(%rbp,%rax,4)
	addl	$1, -8016168(%rbp)
.L23:
	movl	-8016176(%rbp), %eax
	addl	$1, %eax
	cmpl	%eax, -8016168(%rbp)
	jle	.L24
	movl	$0, -8016164(%rbp)
	jmp	.L25
.L26:
	movl	-8016164(%rbp), %eax
	cltq
	movl	$1, -4016032(%rbp,%rax,4)
	movl	-8016176(%rbp), %eax
	leal	1(%rax), %edx
	movl	-8016164(%rbp), %eax
	movslq	%eax, %rcx
	movslq	%edx, %rax
	imulq	$1002, %rax, %rax
	addq	%rcx, %rax
	movl	$1, -4016032(%rbp,%rax,4)
	addl	$1, -8016164(%rbp)
.L25:
	movl	-8016180(%rbp), %eax
	addl	$1, %eax
	cmpl	%eax, -8016164(%rbp)
	jle	.L26
	movl	$0, -8016156(%rbp)
	movl	$0, -8016160(%rbp)
	jmp	.L27
.L46:
	movl	-8016160(%rbp), %eax
	cltq
	movl	-8016080(%rbp,%rax,4), %ecx
	movl	-8016160(%rbp), %eax
	cltq
	movl	-8016128(%rbp,%rax,4), %eax
	movl	-8016156(%rbp), %edx
	movl	%ecx, %esi
	movl	%eax, %edi
	call	Queue
	movq	%rax, -8016152(%rbp)
	movq	-8016152(%rbp), %rax
	movq	%rax, -8016144(%rbp)
	movl	$0, -8016168(%rbp)
	jmp	.L28
.L31:
	movl	$0, -8016164(%rbp)
	jmp	.L29
.L30:
	movl	-8016168(%rbp), %eax
	leal	1(%rax), %edx
	movl	-8016164(%rbp), %eax
	leal	1(%rax), %ecx
	movl	-8016164(%rbp), %eax
	movslq	%eax, %rsi
	movl	-8016168(%rbp), %eax
	cltq
	imulq	$1000, %rax, %rax
	addq	%rsi, %rax
	movl	-8016032(%rbp,%rax,4), %eax
	movslq	%ecx, %rcx
	movslq	%edx, %rdx
	imulq	$1002, %rdx, %rdx
	addq	%rcx, %rdx
	movl	%eax, -4016032(%rbp,%rdx,4)
	addl	$1, -8016164(%rbp)
.L29:
	movl	-8016180(%rbp), %eax
	cmpl	%eax, -8016164(%rbp)
	jl	.L30
	addl	$1, -8016168(%rbp)
.L28:
	movl	-8016176(%rbp), %eax
	cmpl	%eax, -8016168(%rbp)
	jl	.L31
	jmp	.L32
.L42:
	movq	-8016152(%rbp), %rax
	movl	4(%rax), %eax
	leal	1(%rax), %edx
	movl	-8016160(%rbp), %eax
	addl	$1, %eax
	cltq
	movl	-8016128(%rbp,%rax,4), %eax
	cmpl	%eax, %edx
	je	.L33
	movq	-8016152(%rbp), %rax
	movl	4(%rax), %eax
	leal	-1(%rax), %edx
	movl	-8016160(%rbp), %eax
	addl	$1, %eax
	cltq
	movl	-8016128(%rbp,%rax,4), %eax
	cmpl	%eax, %edx
	jne	.L34
.L33:
	movq	-8016152(%rbp), %rax
	movl	(%rax), %edx
	movl	-8016160(%rbp), %eax
	addl	$1, %eax
	cltq
	movl	-8016080(%rbp,%rax,4), %eax
	cmpl	%eax, %edx
	je	.L35
.L34:
	movq	-8016152(%rbp), %rax
	movl	(%rax), %eax
	leal	1(%rax), %edx
	movl	-8016160(%rbp), %eax
	addl	$1, %eax
	cltq
	movl	-8016080(%rbp,%rax,4), %eax
	cmpl	%eax, %edx
	je	.L36
	movq	-8016152(%rbp), %rax
	movl	(%rax), %eax
	leal	-1(%rax), %edx
	movl	-8016160(%rbp), %eax
	addl	$1, %eax
	cltq
	movl	-8016080(%rbp,%rax,4), %eax
	cmpl	%eax, %edx
	jne	.L37
.L36:
	movq	-8016152(%rbp), %rax
	movl	4(%rax), %edx
	movl	-8016160(%rbp), %eax
	addl	$1, %eax
	cltq
	movl	-8016128(%rbp,%rax,4), %eax
	cmpl	%eax, %edx
	je	.L35
.L37:
	movq	-8016152(%rbp), %rax
	movl	4(%rax), %eax
	leal	1(%rax), %edx
	movq	-8016152(%rbp), %rax
	movl	(%rax), %eax
	movslq	%eax, %rcx
	movslq	%edx, %rax
	imulq	$1002, %rax, %rax
	addq	%rcx, %rax
	movl	-4016032(%rbp,%rax,4), %eax
	testl	%eax, %eax
	jne	.L38
	movq	-8016152(%rbp), %rax
	movl	4(%rax), %eax
	leal	1(%rax), %edx
	movq	-8016152(%rbp), %rax
	movl	(%rax), %eax
	movslq	%eax, %rcx
	movslq	%edx, %rax
	imulq	$1002, %rax, %rax
	addq	%rcx, %rax
	movl	$1, -4016032(%rbp,%rax,4)
	movq	-8016152(%rbp), %rax
	movl	8(%rax), %eax
	leal	1(%rax), %ecx
	movq	-8016152(%rbp), %rax
	movl	(%rax), %edx
	movq	-8016152(%rbp), %rax
	movl	4(%rax), %eax
	leal	1(%rax), %esi
	movq	-8016144(%rbp), %rax
	movq	%rax, %rdi
	call	push
	movq	%rax, -8016144(%rbp)
.L38:
	movq	-8016152(%rbp), %rax
	movl	4(%rax), %eax
	leal	-1(%rax), %edx
	movq	-8016152(%rbp), %rax
	movl	(%rax), %eax
	movslq	%eax, %rcx
	movslq	%edx, %rax
	imulq	$1002, %rax, %rax
	addq	%rcx, %rax
	movl	-4016032(%rbp,%rax,4), %eax
	testl	%eax, %eax
	jne	.L39
	movq	-8016152(%rbp), %rax
	movl	4(%rax), %eax
	leal	-1(%rax), %edx
	movq	-8016152(%rbp), %rax
	movl	(%rax), %eax
	movslq	%eax, %rcx
	movslq	%edx, %rax
	imulq	$1002, %rax, %rax
	addq	%rcx, %rax
	movl	$1, -4016032(%rbp,%rax,4)
	movq	-8016152(%rbp), %rax
	movl	8(%rax), %eax
	leal	1(%rax), %ecx
	movq	-8016152(%rbp), %rax
	movl	(%rax), %edx
	movq	-8016152(%rbp), %rax
	movl	4(%rax), %eax
	leal	-1(%rax), %esi
	movq	-8016144(%rbp), %rax
	movq	%rax, %rdi
	call	push
	movq	%rax, -8016144(%rbp)
.L39:
	movq	-8016152(%rbp), %rax
	movl	4(%rax), %edx
	movq	-8016152(%rbp), %rax
	movl	(%rax), %eax
	subl	$1, %eax
	movslq	%eax, %rcx
	movslq	%edx, %rax
	imulq	$1002, %rax, %rax
	addq	%rcx, %rax
	movl	-4016032(%rbp,%rax,4), %eax
	testl	%eax, %eax
	jne	.L40
	movq	-8016152(%rbp), %rax
	movl	4(%rax), %edx
	movq	-8016152(%rbp), %rax
	movl	(%rax), %eax
	subl	$1, %eax
	movslq	%eax, %rcx
	movslq	%edx, %rax
	imulq	$1002, %rax, %rax
	addq	%rcx, %rax
	movl	$1, -4016032(%rbp,%rax,4)
	movq	-8016152(%rbp), %rax
	movl	8(%rax), %eax
	leal	1(%rax), %ecx
	movq	-8016152(%rbp), %rax
	movl	(%rax), %eax
	leal	-1(%rax), %edx
	movq	-8016152(%rbp), %rax
	movl	4(%rax), %esi
	movq	-8016144(%rbp), %rax
	movq	%rax, %rdi
	call	push
	movq	%rax, -8016144(%rbp)
.L40:
	movq	-8016152(%rbp), %rax
	movl	4(%rax), %edx
	movq	-8016152(%rbp), %rax
	movl	(%rax), %eax
	addl	$1, %eax
	movslq	%eax, %rcx
	movslq	%edx, %rax
	imulq	$1002, %rax, %rax
	addq	%rcx, %rax
	movl	-4016032(%rbp,%rax,4), %eax
	testl	%eax, %eax
	jne	.L41
	movq	-8016152(%rbp), %rax
	movl	4(%rax), %edx
	movq	-8016152(%rbp), %rax
	movl	(%rax), %eax
	addl	$1, %eax
	movslq	%eax, %rcx
	movslq	%edx, %rax
	imulq	$1002, %rax, %rax
	addq	%rcx, %rax
	movl	$1, -4016032(%rbp,%rax,4)
	movq	-8016152(%rbp), %rax
	movl	8(%rax), %eax
	leal	1(%rax), %ecx
	movq	-8016152(%rbp), %rax
	movl	(%rax), %eax
	leal	1(%rax), %edx
	movq	-8016152(%rbp), %rax
	movl	4(%rax), %esi
	movq	-8016144(%rbp), %rax
	movq	%rax, %rdi
	call	push
	movq	%rax, -8016144(%rbp)
.L41:
	movq	-8016152(%rbp), %rax
	movq	%rax, %rdi
	call	delhead
	movq	%rax, -8016152(%rbp)
.L32:
	cmpq	$0, -8016152(%rbp)
	jne	.L42
.L35:
	cmpq	$0, -8016152(%rbp)
	je	.L43
	movq	-8016152(%rbp), %rax
	movl	8(%rax), %eax
	addl	$1, %eax
	movl	%eax, -8016156(%rbp)
	movq	-8016152(%rbp), %rax
	movq	%rax, %rdi
	call	allfree
	jmp	.L49
.L43:
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	movl	$0, %eax
	jmp	.L47
.L49:
	addl	$1, -8016160(%rbp)
.L27:
	movl	-8016172(%rbp), %eax
	cmpl	%eax, -8016160(%rbp)
	jl	.L46
	movl	-8016156(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
.L47:
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L48
	call	__stack_chk_fail@PLT
.L48:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE10:
	.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	allfree
	.type	allfree, @function
allfree:
.LFB39:
	.cfi_startproc
	endbr64
	testq	%rdi, %rdi
	je	.L1
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset 3, -16
	movq	16(%rdi), %rbx
	testq	%rbx, %rbx
	je	.L3
	.p2align 4,,10
	.p2align 3
.L4:
	call	free@PLT
	movq	%rbx, %rdi
	movq	16(%rbx), %rbx
	testq	%rbx, %rbx
	jne	.L4
.L3:
	popq	%rbx
	.cfi_restore 3
	.cfi_def_cfa_offset 8
	jmp	free@PLT
	.p2align 4,,10
	.p2align 3
.L1:
	ret
	.cfi_endproc
.LFE39:
	.size	allfree, .-allfree
	.p2align 4
	.globl	push
	.type	push, @function
push:
.LFB40:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movd	%edx, %xmm0
	movd	%esi, %xmm1
	pushq	%rbx
	.cfi_def_cfa_offset 24
	.cfi_offset 3, -24
	punpckldq	%xmm1, %xmm0
	subq	$24, %rsp
	.cfi_def_cfa_offset 48
	movq	%xmm0, 8(%rsp)
	testq	%rdi, %rdi
	je	.L15
	movq	%rdi, %rbx
	movl	$24, %edi
	movl	%ecx, %ebp
	call	malloc@PLT
	movq	8(%rsp), %xmm0
	movq	%rax, 16(%rbx)
	movq	$0, 16(%rax)
	movl	%ebp, 8(%rax)
	movq	%xmm0, (%rax)
	addq	$24, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 24
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L15:
	.cfi_restore_state
	addq	$24, %rsp
	.cfi_def_cfa_offset 24
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE40:
	.size	push, .-push
	.p2align 4
	.globl	Queue
	.type	Queue, @function
Queue:
.LFB41:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	movl	%edx, %r12d
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	movl	%edi, %ebp
	movl	$24, %edi
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	movl	%esi, %ebx
	call	malloc@PLT
	movd	%ebx, %xmm0
	movd	%ebp, %xmm1
	punpckldq	%xmm1, %xmm0
	movq	$0, 16(%rax)
	movl	%r12d, 8(%rax)
	movq	%xmm0, (%rax)
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE41:
	.size	Queue, .-Queue
	.p2align 4
	.globl	delhead
	.type	delhead, @function
delhead:
.LFB42:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	testq	%rdi, %rdi
	je	.L21
	movq	16(%rdi), %r12
	call	free@PLT
	movq	%r12, %rax
	popq	%r12
	.cfi_remember_state
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L21:
	.cfi_restore_state
	xorl	%r12d, %r12d
	movq	%r12, %rax
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE42:
	.size	delhead, .-delhead
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d %d %d"
.LC2:
	.string	"%d\n"
.LC3:
	.string	"Incorrect Data"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB43:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	leaq	-8015872(%rsp), %r11
	.cfi_def_cfa 11, 8015928
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	.cfi_def_cfa_register 7
	subq	$328, %rsp
	.cfi_def_cfa_offset 8016256
	movl	$1001, %edi
	movq	%fs:40, %rax
	movq	%rax, 8016184(%rsp)
	xorl	%eax, %eax
	call	malloc@PLT
	movq	%rax, %rdi
	movq	%rax, %r12
	xorl	%eax, %eax
	call	gets@PLT
	leaq	56(%rsp), %rdx
	movq	%r12, %rdi
	xorl	%eax, %eax
	leaq	52(%rsp), %rcx
	leaq	60(%rsp), %r8
	leaq	.LC0(%rip), %rsi
	call	__isoc99_sscanf@PLT
	movl	56(%rsp), %edx
	testl	%edx, %edx
	jle	.L24
	leaq	160(%rsp), %r14
	xorl	%r13d, %r13d
	movl	$1, %r15d
	.p2align 4,,10
	.p2align 3
.L31:
	movq	%r12, %rdi
	xorl	%eax, %eax
	addl	$1, %r13d
	call	gets@PLT
	movl	52(%rsp), %edi
	testl	%edi, %edi
	jle	.L26
	leal	1(%rdi), %r8d
	movl	$1, %edx
	xorl	%esi, %esi
	jmp	.L29
	.p2align 4,,10
	.p2align 3
.L95:
	subl	$48, %eax
	movsbq	%al, %rax
	movl	%edx, 112(%rsp,%rax,4)
	addq	$1, %rdx
	movl	%r13d, 64(%rsp,%rax,4)
	cmpq	%r8, %rdx
	je	.L94
.L29:
	movzbl	-1(%r12,%rdx), %eax
	xorl	%ecx, %ecx
	cmpb	$88, %al
	sete	%cl
	movl	%ecx, -4(%r14,%rdx,4)
	leal	-49(%rax), %ecx
	cmpb	$8, %cl
	jbe	.L95
	cmpb	$83, %al
	cmove	%edx, %ebp
	cmove	%r13d, %ebx
	cmove	%r15d, %esi
	addq	$1, %rdx
	cmpq	%r8, %rdx
	jne	.L29
.L94:
	testb	%sil, %sil
	je	.L26
	movl	%ebp, 112(%rsp)
	movl	%ebx, 64(%rsp)
.L26:
	movl	56(%rsp), %edx
	addq	$4000, %r14
	cmpl	%r13d, %edx
	jg	.L31
.L32:
	movl	%edx, %r8d
	leal	1(%rdi), %r9d
	addl	$1, %r8d
	js	.L37
	movl	%r8d, %ecx
	leaq	4000160(%rsp), %rax
	imulq	$4008, %rcx, %rcx
	leaq	4004168(%rsp,%rcx), %rsi
	movslq	%r9d, %rcx
	.p2align 4,,10
	.p2align 3
.L36:
	movl	$1, (%rax)
	movl	$1, (%rax,%rcx,4)
	addq	$4008, %rax
	cmpq	%rsi, %rax
	jne	.L36
.L37:
	testl	%r9d, %r9d
	js	.L35
	movslq	%edx, %rcx
	addq	$1, %rcx
	imulq	$4008, %rcx, %rcx
	leaq	-4(%rcx), %rax
	cmpq	$8, %rax
	jbe	.L40
	cmpl	$3, %r9d
	jbe	.L40
	leal	2(%rdi), %r10d
	leaq	4000160(%rsp), %r9
	movdqa	.LC1(%rip), %xmm0
	xorl	%eax, %eax
	movl	%r10d, %esi
	addq	%r9, %rcx
	shrl	$2, %esi
	salq	$4, %rsi
.L41:
	movaps	%xmm0, (%r9,%rax)
	movups	%xmm0, (%rcx,%rax)
	addq	$16, %rax
	cmpq	%rax, %rsi
	jne	.L41
	movl	%r10d, %ecx
	andl	$-4, %ecx
	andl	$3, %r10d
	je	.L35
	movslq	%r8d, %rax
	movslq	%ecx, %rsi
	leal	1(%rcx), %r8d
	imulq	$1002, %rax, %rax
	movl	$1, 4000160(%rsp,%rsi,4)
	addq	%rax, %rsi
	movl	$1, 4000160(%rsp,%rsi,4)
	cmpl	%edi, %ecx
	jg	.L35
	movslq	%r8d, %rsi
	addl	$2, %ecx
	movl	$1, 4000160(%rsp,%rsi,4)
	addq	%rax, %rsi
	movl	$1, 4000160(%rsp,%rsi,4)
	cmpl	%edi, %r8d
	jg	.L35
	movslq	%ecx, %rcx
	movl	$1, 4000160(%rsp,%rcx,4)
	addq	%rcx, %rax
	movl	$1, 4000160(%rsp,%rax,4)
.L35:
	movl	60(%rsp), %r9d
	xorl	%r12d, %r12d
	testl	%r9d, %r9d
	jle	.L39
	leaq	112(%rsp), %rax
	movl	64(%rsp), %r15d
	xorl	%r12d, %r12d
	movq	$1, 16(%rsp)
	movq	%rax, 24(%rsp)
	leaq	64(%rsp), %rax
	movq	16(%rsp), %rbx
	movq	%rax, 32(%rsp)
	leaq	4008180(%rsp), %rax
	movq	%rax, 40(%rsp)
	.p2align 4,,10
	.p2align 3
.L56:
	movq	24(%rsp), %rax
	movl	$24, %edi
	movl	%edx, 4(%rsp)
	movl	-4(%rax,%rbx,4), %r13d
	call	malloc@PLT
	movd	%r15d, %xmm5
	movl	4(%rsp), %edx
	movd	%r13d, %xmm0
	movq	$0, 16(%rax)
	movq	%rax, %rbx
	punpckldq	%xmm5, %xmm0
	movl	%r12d, 8(%rax)
	movq	%xmm0, (%rax)
	testl	%edx, %edx
	jle	.L45
	movslq	52(%rsp), %rax
	testl	%eax, %eax
	jle	.L45
	leal	-1(%rdx), %r12d
	leaq	4004172(%rsp), %rdi
	imulq	$4008, %r12, %r12
	leaq	160(%rsp), %r14
	addq	40(%rsp), %r12
	leaq	0(,%rax,4), %rbp
	.p2align 4,,10
	.p2align 3
.L47:
	movq	%r14, %rsi
	movq	%rbp, %rdx
	addq	$4000, %r14
	call	memcpy@PLT
	movq	%rax, %rdi
	addq	$4008, %rdi
	cmpq	%r12, %rdi
	jne	.L47
.L45:
	movq	32(%rsp), %rcx
	movq	16(%rsp), %rax
	movq	%rbx, %r14
	movl	(%rcx,%rax,4), %ebp
	movq	24(%rsp), %rcx
	movl	(%rcx,%rax,4), %eax
	movl	%eax, 4(%rsp)
	jmp	.L54
	.p2align 4,,10
	.p2align 3
.L92:
	movq	16(%r14), %r12
	movq	%r14, %rdi
	call	free@PLT
	testq	%r12, %r12
	je	.L53
.L59:
	movl	4(%r12), %r15d
	movl	(%r12), %r13d
	movq	%r12, %r14
.L54:
	leal	1(%r15), %eax
	movd	%r13d, %xmm0
	movd	%eax, %xmm1
	punpckldq	%xmm1, %xmm0
	cmpl	%ebp, %eax
	je	.L48
	leal	-1(%r15), %edx
	cmpl	%ebp, %edx
	je	.L48
.L49:
	movl	4(%rsp), %esi
	leal	1(%r13), %edx
	cmpl	%esi, %edx
	je	.L51
	leal	-1(%r13), %edx
	cmpl	%esi, %edx
	je	.L51
.L52:
	cltq
	movslq	%r13d, %rdx
	imulq	$1002, %rax, %rax
	addq	%rdx, %rax
	movl	4000160(%rsp,%rax,4), %ecx
	testl	%ecx, %ecx
	jne	.L66
	movl	$1, 4000160(%rsp,%rax,4)
	movl	8(%r14), %eax
	movl	$24, %edi
	movq	%xmm0, 8(%rsp)
	leal	1(%rax), %r13d
	call	malloc@PLT
	movq	8(%rsp), %xmm0
	movq	%rax, 16(%rbx)
	movq	%rax, %rbx
	movq	%xmm0, (%rax)
	movslq	(%r14), %rdx
	movl	4(%r14), %r15d
	movq	$0, 16(%rax)
	movl	%r13d, 8(%rax)
	movq	%rdx, %r13
.L66:
	leal	-1(%r15), %eax
	movd	%r13d, %xmm0
	movd	%eax, %xmm4
	cltq
	imulq	$1002, %rax, %rax
	punpckldq	%xmm4, %xmm0
	addq	%rdx, %rax
	movl	4000160(%rsp,%rax,4), %esi
	testl	%esi, %esi
	jne	.L64
	movl	$1, 4000160(%rsp,%rax,4)
	movl	8(%r14), %eax
	movl	$24, %edi
	movq	%xmm0, 8(%rsp)
	leal	1(%rax), %r13d
	call	malloc@PLT
	movq	8(%rsp), %xmm0
	movq	%rax, 16(%rbx)
	movq	%rax, %rbx
	movq	$0, 16(%rax)
	movq	%xmm0, (%rax)
	movl	4(%r14), %r15d
	movl	%r13d, 8(%rax)
	movl	(%r14), %r13d
.L64:
	leal	-1(%r13), %eax
	movd	%r15d, %xmm3
	movd	%eax, %xmm0
	movslq	%eax, %rdx
	movslq	%r15d, %rax
	imulq	$1002, %rax, %rsi
	punpckldq	%xmm3, %xmm0
	addq	%rsi, %rdx
	movl	4000160(%rsp,%rdx,4), %edi
	testl	%edi, %edi
	jne	.L62
	movl	8(%r14), %eax
	movl	$24, %edi
	movq	%xmm0, 8(%rsp)
	movl	$1, 4000160(%rsp,%rdx,4)
	leal	1(%rax), %r13d
	call	malloc@PLT
	movq	8(%rsp), %xmm0
	movq	%rax, 16(%rbx)
	movq	%rax, %rbx
	movq	%xmm0, (%rax)
	movl	4(%r14), %r15d
	movl	%r13d, 8(%rax)
	movl	(%r14), %r13d
	movq	$0, 16(%rax)
	movslq	%r15d, %rax
.L62:
	imulq	$1002, %rax, %rax
	leal	1(%r13), %ecx
	movd	%r15d, %xmm2
	movd	%ecx, %xmm0
	movslq	%ecx, %rcx
	punpckldq	%xmm2, %xmm0
	addq	%rcx, %rax
	movl	4000160(%rsp,%rax,4), %r8d
	testl	%r8d, %r8d
	jne	.L92
	movl	$1, 4000160(%rsp,%rax,4)
	movl	8(%r14), %eax
	movl	$24, %edi
	movq	%xmm0, 8(%rsp)
	leal	1(%rax), %r12d
	call	malloc@PLT
	movq	8(%rsp), %xmm0
	movq	%r14, %rdi
	movq	%rax, 16(%rbx)
	movq	%rax, %r13
	movq	$0, 16(%rax)
	movl	%r12d, 8(%rax)
	movq	16(%r14), %r12
	movq	%xmm0, (%rax)
	call	free@PLT
	testq	%r12, %r12
	je	.L53
	movq	%r13, %rbx
	jmp	.L59
	.p2align 4,,10
	.p2align 3
.L48:
	cmpl	4(%rsp), %r13d
	jne	.L49
.L50:
	movl	8(%r14), %eax
	movq	16(%r14), %rbx
	leal	1(%rax), %r12d
	testq	%rbx, %rbx
	je	.L57
	.p2align 4,,10
	.p2align 3
.L55:
	movq	%r14, %rdi
	movq	%rbx, %r14
	call	free@PLT
	movq	16(%rbx), %rbx
	testq	%rbx, %rbx
	jne	.L55
.L57:
	movq	%r14, %rdi
	call	free@PLT
	movq	16(%rsp), %rax
	cmpl	%eax, 60(%rsp)
	jle	.L39
	addq	$1, %rax
	movl	56(%rsp), %edx
	movl	%ebp, %r15d
	movq	%rax, 16(%rsp)
	movq	%rax, %rbx
	jmp	.L56
	.p2align 4,,10
	.p2align 3
.L51:
	cmpl	%ebp, %r15d
	jne	.L52
	jmp	.L50
.L39:
	movl	%r12d, %edx
	leaq	.LC2(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L58:
	movq	8016184(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L96
	addq	$8016200, %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
.L53:
	.cfi_restore_state
	leaq	.LC3(%rip), %rdi
	call	puts@PLT
	jmp	.L58
.L40:
	movl	%r9d, %r9d
	leaq	4000160(%rsp), %rax
	leaq	4000164(%rsp,%r9,4), %rsi
.L43:
	movl	$1, (%rax)
	addq	$4, %rax
	movl	$1, -4(%rax,%rcx)
	cmpq	%rsi, %rax
	jne	.L43
	jmp	.L35
.L24:
	movl	52(%rsp), %edi
	jmp	.L32
.L96:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE43:
	.size	main, .-main
	.section	.rodata.cst16,"aM",@progbits,16
	.align 16
.LC1:
	.long	1
	.long	1
	.long	1
	.long	1
	.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	allfree
	.type	allfree, @function
allfree:
.LFB39:
	.cfi_startproc
	endbr64
	testq	%rdi, %rdi
	je	.L1
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset 3, -16
	movq	16(%rdi), %rbx
	testq	%rbx, %rbx
	je	.L3
	.p2align 4,,10
	.p2align 3
.L4:
	call	free@PLT
	movq	%rbx, %rdi
	movq	16(%rbx), %rbx
	testq	%rbx, %rbx
	jne	.L4
.L3:
	popq	%rbx
	.cfi_restore 3
	.cfi_def_cfa_offset 8
	jmp	free@PLT
	.p2align 4,,10
	.p2align 3
.L1:
	ret
	.cfi_endproc
.LFE39:
	.size	allfree, .-allfree
	.p2align 4
	.globl	push
	.type	push, @function
push:
.LFB40:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movd	%edx, %xmm0
	movd	%esi, %xmm1
	pushq	%rbx
	.cfi_def_cfa_offset 24
	.cfi_offset 3, -24
	punpckldq	%xmm1, %xmm0
	subq	$24, %rsp
	.cfi_def_cfa_offset 48
	movq	%xmm0, 8(%rsp)
	testq	%rdi, %rdi
	je	.L15
	movq	%rdi, %rbx
	movl	$24, %edi
	movl	%ecx, %ebp
	call	malloc@PLT
	movq	8(%rsp), %xmm0
	movq	%rax, 16(%rbx)
	movq	$0, 16(%rax)
	movl	%ebp, 8(%rax)
	movq	%xmm0, (%rax)
	addq	$24, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 24
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L15:
	.cfi_restore_state
	addq	$24, %rsp
	.cfi_def_cfa_offset 24
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE40:
	.size	push, .-push
	.p2align 4
	.globl	Queue
	.type	Queue, @function
Queue:
.LFB41:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	movl	%edx, %r12d
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	movl	%edi, %ebp
	movl	$24, %edi
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	movl	%esi, %ebx
	call	malloc@PLT
	movd	%ebx, %xmm0
	movd	%ebp, %xmm1
	punpckldq	%xmm1, %xmm0
	movq	$0, 16(%rax)
	movl	%r12d, 8(%rax)
	movq	%xmm0, (%rax)
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE41:
	.size	Queue, .-Queue
	.p2align 4
	.globl	delhead
	.type	delhead, @function
delhead:
.LFB42:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	testq	%rdi, %rdi
	je	.L21
	movq	16(%rdi), %r12
	call	free@PLT
	movq	%r12, %rax
	popq	%r12
	.cfi_remember_state
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L21:
	.cfi_restore_state
	xorl	%r12d, %r12d
	movq	%r12, %rax
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE42:
	.size	delhead, .-delhead
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d %d %d"
.LC2:
	.string	"%d\n"
.LC3:
	.string	"Incorrect Data"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB43:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	leaq	-8015872(%rsp), %r11
	.cfi_def_cfa 11, 8015928
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	.cfi_def_cfa_register 7
	subq	$328, %rsp
	.cfi_def_cfa_offset 8016256
	movl	$1001, %edi
	movq	%fs:40, %rax
	movq	%rax, 8016184(%rsp)
	xorl	%eax, %eax
	call	malloc@PLT
	movq	%rax, %rdi
	movq	%rax, %r12
	xorl	%eax, %eax
	call	gets@PLT
	leaq	56(%rsp), %rdx
	movq	%r12, %rdi
	xorl	%eax, %eax
	leaq	52(%rsp), %rcx
	leaq	60(%rsp), %r8
	leaq	.LC0(%rip), %rsi
	call	__isoc99_sscanf@PLT
	movl	56(%rsp), %edx
	testl	%edx, %edx
	jle	.L24
	leaq	160(%rsp), %r14
	xorl	%r13d, %r13d
	movl	$1, %r15d
	.p2align 4,,10
	.p2align 3
.L31:
	movq	%r12, %rdi
	xorl	%eax, %eax
	addl	$1, %r13d
	call	gets@PLT
	movl	52(%rsp), %edi
	testl	%edi, %edi
	jle	.L26
	leal	1(%rdi), %r8d
	movl	$1, %edx
	xorl	%esi, %esi
	jmp	.L29
	.p2align 4,,10
	.p2align 3
.L95:
	subl	$48, %eax
	movsbq	%al, %rax
	movl	%edx, 112(%rsp,%rax,4)
	addq	$1, %rdx
	movl	%r13d, 64(%rsp,%rax,4)
	cmpq	%r8, %rdx
	je	.L94
.L29:
	movzbl	-1(%r12,%rdx), %eax
	xorl	%ecx, %ecx
	cmpb	$88, %al
	sete	%cl
	movl	%ecx, -4(%r14,%rdx,4)
	leal	-49(%rax), %ecx
	cmpb	$8, %cl
	jbe	.L95
	cmpb	$83, %al
	cmove	%edx, %ebp
	cmove	%r13d, %ebx
	cmove	%r15d, %esi
	addq	$1, %rdx
	cmpq	%r8, %rdx
	jne	.L29
.L94:
	testb	%sil, %sil
	je	.L26
	movl	%ebp, 112(%rsp)
	movl	%ebx, 64(%rsp)
.L26:
	movl	56(%rsp), %edx
	addq	$4000, %r14
	cmpl	%r13d, %edx
	jg	.L31
.L32:
	movl	%edx, %r8d
	leal	1(%rdi), %r9d
	addl	$1, %r8d
	js	.L37
	movl	%r8d, %ecx
	leaq	4000160(%rsp), %rax
	imulq	$4008, %rcx, %rcx
	leaq	4004168(%rsp,%rcx), %rsi
	movslq	%r9d, %rcx
	.p2align 4,,10
	.p2align 3
.L36:
	movl	$1, (%rax)
	movl	$1, (%rax,%rcx,4)
	addq	$4008, %rax
	cmpq	%rsi, %rax
	jne	.L36
.L37:
	testl	%r9d, %r9d
	js	.L35
	movslq	%edx, %rcx
	addq	$1, %rcx
	imulq	$4008, %rcx, %rcx
	leaq	-4(%rcx), %rax
	cmpq	$8, %rax
	jbe	.L40
	cmpl	$3, %r9d
	jbe	.L40
	leal	2(%rdi), %r10d
	leaq	4000160(%rsp), %r9
	movdqa	.LC1(%rip), %xmm0
	xorl	%eax, %eax
	movl	%r10d, %esi
	addq	%r9, %rcx
	shrl	$2, %esi
	salq	$4, %rsi
.L41:
	movaps	%xmm0, (%r9,%rax)
	movups	%xmm0, (%rcx,%rax)
	addq	$16, %rax
	cmpq	%rax, %rsi
	jne	.L41
	movl	%r10d, %ecx
	andl	$-4, %ecx
	andl	$3, %r10d
	je	.L35
	movslq	%r8d, %rax
	movslq	%ecx, %rsi
	leal	1(%rcx), %r8d
	imulq	$1002, %rax, %rax
	movl	$1, 4000160(%rsp,%rsi,4)
	addq	%rax, %rsi
	movl	$1, 4000160(%rsp,%rsi,4)
	cmpl	%edi, %ecx
	jg	.L35
	movslq	%r8d, %rsi
	addl	$2, %ecx
	movl	$1, 4000160(%rsp,%rsi,4)
	addq	%rax, %rsi
	movl	$1, 4000160(%rsp,%rsi,4)
	cmpl	%edi, %r8d
	jg	.L35
	movslq	%ecx, %rcx
	movl	$1, 4000160(%rsp,%rcx,4)
	addq	%rcx, %rax
	movl	$1, 4000160(%rsp,%rax,4)
.L35:
	movl	60(%rsp), %r9d
	xorl	%r12d, %r12d
	testl	%r9d, %r9d
	jle	.L39
	leaq	112(%rsp), %rax
	movl	64(%rsp), %r15d
	xorl	%r12d, %r12d
	movq	$1, 16(%rsp)
	movq	%rax, 24(%rsp)
	leaq	64(%rsp), %rax
	movq	16(%rsp), %rbx
	movq	%rax, 32(%rsp)
	leaq	4008180(%rsp), %rax
	movq	%rax, 40(%rsp)
	.p2align 4,,10
	.p2align 3
.L56:
	movq	24(%rsp), %rax
	movl	$24, %edi
	movl	%edx, 4(%rsp)
	movl	-4(%rax,%rbx,4), %r13d
	call	malloc@PLT
	movd	%r15d, %xmm5
	movl	4(%rsp), %edx
	movd	%r13d, %xmm0
	movq	$0, 16(%rax)
	movq	%rax, %rbx
	punpckldq	%xmm5, %xmm0
	movl	%r12d, 8(%rax)
	movq	%xmm0, (%rax)
	testl	%edx, %edx
	jle	.L45
	movslq	52(%rsp), %rax
	testl	%eax, %eax
	jle	.L45
	leal	-1(%rdx), %r12d
	leaq	4004172(%rsp), %rdi
	imulq	$4008, %r12, %r12
	leaq	160(%rsp), %r14
	addq	40(%rsp), %r12
	leaq	0(,%rax,4), %rbp
	.p2align 4,,10
	.p2align 3
.L47:
	movq	%r14, %rsi
	movq	%rbp, %rdx
	addq	$4000, %r14
	call	memcpy@PLT
	movq	%rax, %rdi
	addq	$4008, %rdi
	cmpq	%r12, %rdi
	jne	.L47
.L45:
	movq	32(%rsp), %rcx
	movq	16(%rsp), %rax
	movq	%rbx, %r14
	movl	(%rcx,%rax,4), %ebp
	movq	24(%rsp), %rcx
	movl	(%rcx,%rax,4), %eax
	movl	%eax, 4(%rsp)
	jmp	.L54
	.p2align 4,,10
	.p2align 3
.L92:
	movq	16(%r14), %r12
	movq	%r14, %rdi
	call	free@PLT
	testq	%r12, %r12
	je	.L53
.L59:
	movl	4(%r12), %r15d
	movl	(%r12), %r13d
	movq	%r12, %r14
.L54:
	leal	1(%r15), %eax
	movd	%r13d, %xmm0
	movd	%eax, %xmm1
	punpckldq	%xmm1, %xmm0
	cmpl	%ebp, %eax
	je	.L48
	leal	-1(%r15), %edx
	cmpl	%ebp, %edx
	je	.L48
.L49:
	movl	4(%rsp), %esi
	leal	1(%r13), %edx
	cmpl	%esi, %edx
	je	.L51
	leal	-1(%r13), %edx
	cmpl	%esi, %edx
	je	.L51
.L52:
	cltq
	movslq	%r13d, %rdx
	imulq	$1002, %rax, %rax
	addq	%rdx, %rax
	movl	4000160(%rsp,%rax,4), %ecx
	testl	%ecx, %ecx
	jne	.L66
	movl	$1, 4000160(%rsp,%rax,4)
	movl	8(%r14), %eax
	movl	$24, %edi
	movq	%xmm0, 8(%rsp)
	leal	1(%rax), %r13d
	call	malloc@PLT
	movq	8(%rsp), %xmm0
	movq	%rax, 16(%rbx)
	movq	%rax, %rbx
	movq	%xmm0, (%rax)
	movslq	(%r14), %rdx
	movl	4(%r14), %r15d
	movq	$0, 16(%rax)
	movl	%r13d, 8(%rax)
	movq	%rdx, %r13
.L66:
	leal	-1(%r15), %eax
	movd	%r13d, %xmm0
	movd	%eax, %xmm4
	cltq
	imulq	$1002, %rax, %rax
	punpckldq	%xmm4, %xmm0
	addq	%rdx, %rax
	movl	4000160(%rsp,%rax,4), %esi
	testl	%esi, %esi
	jne	.L64
	movl	$1, 4000160(%rsp,%rax,4)
	movl	8(%r14), %eax
	movl	$24, %edi
	movq	%xmm0, 8(%rsp)
	leal	1(%rax), %r13d
	call	malloc@PLT
	movq	8(%rsp), %xmm0
	movq	%rax, 16(%rbx)
	movq	%rax, %rbx
	movq	$0, 16(%rax)
	movq	%xmm0, (%rax)
	movl	4(%r14), %r15d
	movl	%r13d, 8(%rax)
	movl	(%r14), %r13d
.L64:
	leal	-1(%r13), %eax
	movd	%r15d, %xmm3
	movd	%eax, %xmm0
	movslq	%eax, %rdx
	movslq	%r15d, %rax
	imulq	$1002, %rax, %rsi
	punpckldq	%xmm3, %xmm0
	addq	%rsi, %rdx
	movl	4000160(%rsp,%rdx,4), %edi
	testl	%edi, %edi
	jne	.L62
	movl	8(%r14), %eax
	movl	$24, %edi
	movq	%xmm0, 8(%rsp)
	movl	$1, 4000160(%rsp,%rdx,4)
	leal	1(%rax), %r13d
	call	malloc@PLT
	movq	8(%rsp), %xmm0
	movq	%rax, 16(%rbx)
	movq	%rax, %rbx
	movq	%xmm0, (%rax)
	movl	4(%r14), %r15d
	movl	%r13d, 8(%rax)
	movl	(%r14), %r13d
	movq	$0, 16(%rax)
	movslq	%r15d, %rax
.L62:
	imulq	$1002, %rax, %rax
	leal	1(%r13), %ecx
	movd	%r15d, %xmm2
	movd	%ecx, %xmm0
	movslq	%ecx, %rcx
	punpckldq	%xmm2, %xmm0
	addq	%rcx, %rax
	movl	4000160(%rsp,%rax,4), %r8d
	testl	%r8d, %r8d
	jne	.L92
	movl	$1, 4000160(%rsp,%rax,4)
	movl	8(%r14), %eax
	movl	$24, %edi
	movq	%xmm0, 8(%rsp)
	leal	1(%rax), %r12d
	call	malloc@PLT
	movq	8(%rsp), %xmm0
	movq	%r14, %rdi
	movq	%rax, 16(%rbx)
	movq	%rax, %r13
	movq	$0, 16(%rax)
	movl	%r12d, 8(%rax)
	movq	16(%r14), %r12
	movq	%xmm0, (%rax)
	call	free@PLT
	testq	%r12, %r12
	je	.L53
	movq	%r13, %rbx
	jmp	.L59
	.p2align 4,,10
	.p2align 3
.L48:
	cmpl	4(%rsp), %r13d
	jne	.L49
.L50:
	movl	8(%r14), %eax
	movq	16(%r14), %rbx
	leal	1(%rax), %r12d
	testq	%rbx, %rbx
	je	.L57
	.p2align 4,,10
	.p2align 3
.L55:
	movq	%r14, %rdi
	movq	%rbx, %r14
	call	free@PLT
	movq	16(%rbx), %rbx
	testq	%rbx, %rbx
	jne	.L55
.L57:
	movq	%r14, %rdi
	call	free@PLT
	movq	16(%rsp), %rax
	cmpl	%eax, 60(%rsp)
	jle	.L39
	addq	$1, %rax
	movl	56(%rsp), %edx
	movl	%ebp, %r15d
	movq	%rax, 16(%rsp)
	movq	%rax, %rbx
	jmp	.L56
	.p2align 4,,10
	.p2align 3
.L51:
	cmpl	%ebp, %r15d
	jne	.L52
	jmp	.L50
.L39:
	movl	%r12d, %edx
	leaq	.LC2(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L58:
	movq	8016184(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L96
	addq	$8016200, %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
.L53:
	.cfi_restore_state
	leaq	.LC3(%rip), %rdi
	call	puts@PLT
	jmp	.L58
.L40:
	movl	%r9d, %r9d
	leaq	4000160(%rsp), %rax
	leaq	4000164(%rsp,%r9,4), %rsi
.L43:
	movl	$1, (%rax)
	addq	$4, %rax
	movl	$1, -4(%rax,%rcx)
	cmpq	%rsi, %rax
	jne	.L43
	jmp	.L35
.L24:
	movl	52(%rsp), %edi
	jmp	.L32
.L96:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE43:
	.size	main, .-main
	.section	.rodata.cst16,"aM",@progbits,16
	.align 16
.LC1:
	.long	1
	.long	1
	.long	1
	.long	1
	.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>

struct TQueue{
  int x,y,dep;
  struct TQueue* next;
};

void allfree(struct TQueue* q){
  struct TQueue* r[2];
  r[0]=q;
  if(q==0)return;
  r[1]=q->next;
  while(r[1]){
    free(r[0]);
    r[0]=r[1];
    r[1]=r[1]->next;
  }
  free(r[0]);
}

struct TQueue* push(struct TQueue* ed,int y,int x,int d){
  if(ed==0){
    return 0;
  }
  ed->next=(struct TQueue*)malloc(sizeof(struct TQueue));
  ed->next->next=0;
  ed->next->dep=d;
  ed->next->x=x;
  ed->next->y=y;
  return ed->next;
}

struct TQueue* Queue(int y,int x,int d){
  struct TQueue* ret;
  ret=(struct TQueue*)malloc(sizeof(struct TQueue));
  ret->next=0;
  ret->x=x;
  ret->y=y;
  ret->dep=d;
  return ret;
}


struct TQueue* delhead(struct TQueue* st){
  struct TQueue* ret;
  if(!st)return 0;
  ret=st->next;
  free(st);
  return ret;
}




int main(){
  int w,h,n;
  int i,j,k;
  char* s;
  int mp[1000][1000];
  int ts[1002][1002];
  int ret,ls,pt;
  int gy[10],gx[10];
  struct TQueue *st,*ed;
  s=(char*)malloc(sizeof(char)*1001);

  gets(s);
  sscanf(s,"%d %d %d",&h,&w,&n);

  for(i=0;i<h;i++){
    gets(s);
    for(j=0;j<w;j++){
      mp[i][j]=s[j]=='X'?1:0;
      if(s[j]>='1'&&s[j]<='9'){
        gy[s[j]-'0']=i+1;
        gx[s[j]-'0']=j+1;
      }
      if(s[j]=='S'){
        gy[0]=i+1;
        gx[0]=j+1;
      }
    }
  }
  for(i=0;i<h+2;i++){
    ts[i][0]=1;
    ts[i][w+1]=1;
  }
  for(j=0;j<w+2;j++){
    ts[0][j]=1;
    ts[h+1][j]=1;
  }
  ret=0;
  for(k=0;k<n;k++){
    st=Queue(gy[k],gx[k],ret);
    ed=st;
    for(i=0;i<h;i++){
      for(j=0;j<w;j++){
        ts[i+1][j+1]=mp[i][j];
      }
    }

    while(st){
      if(((st->y+1==gy[k+1]||st->y-1==gy[k+1])&&st->x==gx[k+1])
        ||((st->x+1==gx[k+1]||st->x-1==gx[k+1])&&st->y==gy[k+1])){
        break;
      }
      if(ts[st->y+1][st->x]==0){
        ts[st->y+1][st->x]=1;
        ed=push(ed,st->y+1,st->x,st->dep+1);
      }
      if(!ts[st->y-1][st->x]){
        ts[st->y-1][st->x]=1;
        ed=push(ed,st->y-1,st->x,st->dep+1);   
      }
      if(!ts[st->y][st->x-1]){
        ts[st->y][st->x-1]=1;
        ed=push(ed,st->y,st->x-1,st->dep+1);
      }
      if(!ts[st->y][st->x+1]){
        ts[st->y][st->x+1]=1;
        ed=push(ed,st->y,st->x+1,st->dep+1);
      }
      st=delhead(st);
    }
    if(st){
      ret=st->dep+1;
      allfree(st);
    }else{
      printf("Incorrect Data\n");
      return 0;
    }
  }

  printf("%d\n",ret);
  return 0;
}
3 3 1
S..
...
..1

4

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>

struct TQueue{
  int x,y,dep;
  struct TQueue* next;
};

void allfree(struct TQueue* q){
  struct TQueue* r[2];
  r[0]=q;
  if(q==0)return;
  r[1]=q->next;
  while(r[1]){
    free(r[0]);
    r[0]=r[1];
    r[1]=r[1]->next;
  }
  free(r[0]);
}

struct TQueue* push(struct TQueue* ed,int y,int x,int d){
  if(ed==0){
    return 0;
  }
  ed->next=(struct TQueue*)malloc(sizeof(struct TQueue));
  ed->next->next=0;
  ed->next->dep=d;
  ed->next->x=x;
  ed->next->y=y;
  return ed->next;
}

struct TQueue* Queue(int y,int x,int d){
  struct TQueue* ret;
  ret=(struct TQueue*)malloc(sizeof(struct TQueue));
  ret->next=0;
  ret->x=x;
  ret->y=y;
  ret->dep=d;
  return ret;
}


struct TQueue* delhead(struct TQueue* st){
  struct TQueue* ret;
  if(!st)return 0;
  ret=st->next;
  free(st);
  return ret;
}




int main(){
  int w,h,n;
  int i,j,k;
  char* s;
  int mp[1000][1000];
  int ts[1002][1002];
  int ret,ls,pt;
  int gy[10],gx[10];
  struct TQueue *st,*ed;
  s=(char*)malloc(sizeof(char)*1001);

  gets(s);
  sscanf(s,"%d %d %d",&h,&w,&n);

  for(i=0;i<h;i++){
    gets(s);
    for(j=0;j<w;j++){
      mp[i][j]=s[j]=='X'?1:0;
      if(s[j]>='1'&&s[j]<='9'){
        gy[s[j]-'0']=i+1;
        gx[s[j]-'0']=j+1;
      }
      if(s[j]=='S'){
        gy[0]=i+1;
        gx[0]=j+1;
      }
    }
  }
  for(i=0;i<h+2;i++){
    ts[i][0]=1;
    ts[i][w+1]=1;
  }
  for(j=0;j<w+2;j++){
    ts[0][j]=1;
    ts[h+1][j]=1;
  }
  ret=0;
  for(k=0;k<n;k++){
    st=Queue(gy[k],gx[k],ret);
    ed=st;
    for(i=0;i<h;i++){
      for(j=0;j<w;j++){
        ts[i+1][j+1]=mp[i][j];
      }
    }

    while(st){
      if(((st->y+1==gy[k+1]||st->y-1==gy[k+1])&&st->x==gx[k+1])
        ||((st->x+1==gx[k+1]||st->x-1==gx[k+1])&&st->y==gy[k+1])){
        break;
      }
      if(ts[st->y+1][st->x]==0){
        ts[st->y+1][st->x]=1;
        ed=push(ed,st->y+1,st->x,st->dep+1);
      }
      if(!ts[st->y-1][st->x]){
        ts[st->y-1][st->x]=1;
        ed=push(ed,st->y-1,st->x,st->dep+1);   
      }
      if(!ts[st->y][st->x-1]){
        ts[st->y][st->x-1]=1;
        ed=push(ed,st->y,st->x-1,st->dep+1);
      }
      if(!ts[st->y][st->x+1]){
        ts[st->y][st->x+1]=1;
        ed=push(ed,st->y,st->x+1,st->dep+1);
      }
      st=delhead(st);
    }
    if(st){
      ret=st->dep+1;
      allfree(st);
    }else{
      printf("Incorrect Data\n");
      return 0;
    }
  }

  printf("%d\n",ret);
  return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	allfree
	.type	allfree, @function
allfree:
.LFB6:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$48, %rsp
	movq	%rdi, -40(%rbp)
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movq	-40(%rbp), %rax
	movq	%rax, -32(%rbp)
	cmpq	$0, -40(%rbp)
	je	.L7
	movq	-40(%rbp), %rax
	movq	16(%rax), %rax
	movq	%rax, -24(%rbp)
	jmp	.L4
.L5:
	movq	-32(%rbp), %rax
	movq	%rax, %rdi
	call	free@PLT
	movq	-24(%rbp), %rax
	movq	%rax, -32(%rbp)
	movq	-24(%rbp), %rax
	movq	16(%rax), %rax
	movq	%rax, -24(%rbp)
.L4:
	movq	-24(%rbp), %rax
	testq	%rax, %rax
	jne	.L5
	movq	-32(%rbp), %rax
	movq	%rax, %rdi
	call	free@PLT
	jmp	.L1
.L7:
	nop
.L1:
	movq	-8(%rbp), %rax
	subq	%fs:40, %rax
	je	.L6
	call	__stack_chk_fail@PLT
.L6:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	allfree, .-allfree
	.globl	push
	.type	push, @function
push:
.LFB7:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$32, %rsp
	movq	%rdi, -8(%rbp)
	movl	%esi, -12(%rbp)
	movl	%edx, -16(%rbp)
	movl	%ecx, -20(%rbp)
	cmpq	$0, -8(%rbp)
	jne	.L9
	movl	$0, %eax
	jmp	.L10
.L9:
	movl	$24, %edi
	call	malloc@PLT
	movq	%rax, %rdx
	movq	-8(%rbp), %rax
	movq	%rdx, 16(%rax)
	movq	-8(%rbp), %rax
	movq	16(%rax), %rax
	movq	$0, 16(%rax)
	movq	-8(%rbp), %rax
	movq	16(%rax), %rax
	movl	-20(%rbp), %edx
	movl	%edx, 8(%rax)
	movq	-8(%rbp), %rax
	movq	16(%rax), %rax
	movl	-16(%rbp), %edx
	movl	%edx, (%rax)
	movq	-8(%rbp), %rax
	movq	16(%rax), %rax
	movl	-12(%rbp), %edx
	movl	%edx, 4(%rax)
	movq	-8(%rbp), %rax
	movq	16(%rax), %rax
.L10:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.size	push, .-push
	.globl	Queue
	.type	Queue, @function
Queue:
.LFB8:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$32, %rsp
	movl	%edi, -20(%rbp)
	movl	%esi, -24(%rbp)
	movl	%edx, -28(%rbp)
	movl	$24, %edi
	call	malloc@PLT
	movq	%rax, -8(%rbp)
	movq	-8(%rbp), %rax
	movq	$0, 16(%rax)
	movq	-8(%rbp), %rax
	movl	-24(%rbp), %edx
	movl	%edx, (%rax)
	movq	-8(%rbp), %rax
	movl	-20(%rbp), %edx
	movl	%edx, 4(%rax)
	movq	-8(%rbp), %rax
	movl	-28(%rbp), %edx
	movl	%edx, 8(%rax)
	movq	-8(%rbp), %rax
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE8:
	.size	Queue, .-Queue
	.globl	delhead
	.type	delhead, @function
delhead:
.LFB9:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$32, %rsp
	movq	%rdi, -24(%rbp)
	cmpq	$0, -24(%rbp)
	jne	.L14
	movl	$0, %eax
	jmp	.L15
.L14:
	movq	-24(%rbp), %rax
	movq	16(%rax), %rax
	movq	%rax, -8(%rbp)
	movq	-24(%rbp), %rax
	movq	%rax, %rdi
	call	free@PLT
	movq	-8(%rbp), %rax
.L15:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE9:
	.size	delhead, .-delhead
	.section	.rodata
.LC0:
	.string	"%d %d %d"
.LC1:
	.string	"Incorrect Data"
.LC2:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB10:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	leaq	-8015872(%rsp), %r11
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	subq	$320, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	$1001, %edi
	call	malloc@PLT
	movq	%rax, -8016136(%rbp)
	movq	-8016136(%rbp), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	gets@PLT
	leaq	-8016172(%rbp), %rsi
	leaq	-8016180(%rbp), %rcx
	leaq	-8016176(%rbp), %rdx
	movq	-8016136(%rbp), %rax
	movq	%rsi, %r8
	leaq	.LC0(%rip), %rsi
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_sscanf@PLT
	movl	$0, -8016168(%rbp)
	jmp	.L17
.L22:
	movq	-8016136(%rbp), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	gets@PLT
	movl	$0, -8016164(%rbp)
	jmp	.L18
.L21:
	movl	-8016164(%rbp), %eax
	movslq	%eax, %rdx
	movq	-8016136(%rbp), %rax
	addq	%rdx, %rax
	movzbl	(%rax), %eax
	cmpb	$88, %al
	sete	%al
	movzbl	%al, %eax
	movl	-8016164(%rbp), %edx
	movslq	%edx, %rcx
	movl	-8016168(%rbp), %edx
	movslq	%edx, %rdx
	imulq	$1000, %rdx, %rdx
	addq	%rcx, %rdx
	movl	%eax, -8016032(%rbp,%rdx,4)
	movl	-8016164(%rbp), %eax
	movslq	%eax, %rdx
	movq	-8016136(%rbp), %rax
	addq	%rdx, %rax
	movzbl	(%rax), %eax
	cmpb	$48, %al
	jle	.L19
	movl	-8016164(%rbp), %eax
	movslq	%eax, %rdx
	movq	-8016136(%rbp), %rax
	addq	%rdx, %rax
	movzbl	(%rax), %eax
	cmpb	$57, %al
	jg	.L19
	movl	-8016164(%rbp), %eax
	movslq	%eax, %rdx
	movq	-8016136(%rbp), %rax
	addq	%rdx, %rax
	movzbl	(%rax), %eax
	movsbl	%al, %eax
	leal	-48(%rax), %ecx
	movl	-8016168(%rbp), %eax
	leal	1(%rax), %edx
	movslq	%ecx, %rax
	movl	%edx, -8016128(%rbp,%rax,4)
	movl	-8016164(%rbp), %eax
	movslq	%eax, %rdx
	movq	-8016136(%rbp), %rax
	addq	%rdx, %rax
	movzbl	(%rax), %eax
	movsbl	%al, %eax
	leal	-48(%rax), %ecx
	movl	-8016164(%rbp), %eax
	leal	1(%rax), %edx
	movslq	%ecx, %rax
	movl	%edx, -8016080(%rbp,%rax,4)
.L19:
	movl	-8016164(%rbp), %eax
	movslq	%eax, %rdx
	movq	-8016136(%rbp), %rax
	addq	%rdx, %rax
	movzbl	(%rax), %eax
	cmpb	$83, %al
	jne	.L20
	movl	-8016168(%rbp), %eax
	addl	$1, %eax
	movl	%eax, -8016128(%rbp)
	movl	-8016164(%rbp), %eax
	addl	$1, %eax
	movl	%eax, -8016080(%rbp)
.L20:
	addl	$1, -8016164(%rbp)
.L18:
	movl	-8016180(%rbp), %eax
	cmpl	%eax, -8016164(%rbp)
	jl	.L21
	addl	$1, -8016168(%rbp)
.L17:
	movl	-8016176(%rbp), %eax
	cmpl	%eax, -8016168(%rbp)
	jl	.L22
	movl	$0, -8016168(%rbp)
	jmp	.L23
.L24:
	movl	-8016168(%rbp), %eax
	cltq
	imulq	$4008, %rax, %rax
	addq	%rbp, %rax
	subq	$4016032, %rax
	movl	$1, (%rax)
	movl	-8016180(%rbp), %eax
	addl	$1, %eax
	movslq	%eax, %rdx
	movl	-8016168(%rbp), %eax
	cltq
	imulq	$1002, %rax, %rax
	addq	%rdx, %rax
	movl	$1, -4016032(%rbp,%rax,4)
	addl	$1, -8016168(%rbp)
.L23:
	movl	-8016176(%rbp), %eax
	addl	$1, %eax
	cmpl	%eax, -8016168(%rbp)
	jle	.L24
	movl	$0, -8016164(%rbp)
	jmp	.L25
.L26:
	movl	-8016164(%rbp), %eax
	cltq
	movl	$1, -4016032(%rbp,%rax,4)
	movl	-8016176(%rbp), %eax
	leal	1(%rax), %edx
	movl	-8016164(%rbp), %eax
	movslq	%eax, %rcx
	movslq	%edx, %rax
	imulq	$1002, %rax, %rax
	addq	%rcx, %rax
	movl	$1, -4016032(%rbp,%rax,4)
	addl	$1, -8016164(%rbp)
.L25:
	movl	-8016180(%rbp), %eax
	addl	$1, %eax
	cmpl	%eax, -8016164(%rbp)
	jle	.L26
	movl	$0, -8016156(%rbp)
	movl	$0, -8016160(%rbp)
	jmp	.L27
.L46:
	movl	-8016160(%rbp), %eax
	cltq
	movl	-8016080(%rbp,%rax,4), %ecx
	movl	-8016160(%rbp), %eax
	cltq
	movl	-8016128(%rbp,%rax,4), %eax
	movl	-8016156(%rbp), %edx
	movl	%ecx, %esi
	movl	%eax, %edi
	call	Queue
	movq	%rax, -8016152(%rbp)
	movq	-8016152(%rbp), %rax
	movq	%rax, -8016144(%rbp)
	movl	$0, -8016168(%rbp)
	jmp	.L28
.L31:
	movl	$0, -8016164(%rbp)
	jmp	.L29
.L30:
	movl	-8016168(%rbp), %eax
	leal	1(%rax), %edx
	movl	-8016164(%rbp), %eax
	leal	1(%rax), %ecx
	movl	-8016164(%rbp), %eax
	movslq	%eax, %rsi
	movl	-8016168(%rbp), %eax
	cltq
	imulq	$1000, %rax, %rax
	addq	%rsi, %rax
	movl	-8016032(%rbp,%rax,4), %eax
	movslq	%ecx, %rcx
	movslq	%edx, %rdx
	imulq	$1002, %rdx, %rdx
	addq	%rcx, %rdx
	movl	%eax, -4016032(%rbp,%rdx,4)
	addl	$1, -8016164(%rbp)
.L29:
	movl	-8016180(%rbp), %eax
	cmpl	%eax, -8016164(%rbp)
	jl	.L30
	addl	$1, -8016168(%rbp)
.L28:
	movl	-8016176(%rbp), %eax
	cmpl	%eax, -8016168(%rbp)
	jl	.L31
	jmp	.L32
.L42:
	movq	-8016152(%rbp), %rax
	movl	4(%rax), %eax
	leal	1(%rax), %edx
	movl	-8016160(%rbp), %eax
	addl	$1, %eax
	cltq
	movl	-8016128(%rbp,%rax,4), %eax
	cmpl	%eax, %edx
	je	.L33
	movq	-8016152(%rbp), %rax
	movl	4(%rax), %eax
	leal	-1(%rax), %edx
	movl	-8016160(%rbp), %eax
	addl	$1, %eax
	cltq
	movl	-8016128(%rbp,%rax,4), %eax
	cmpl	%eax, %edx
	jne	.L34
.L33:
	movq	-8016152(%rbp), %rax
	movl	(%rax), %edx
	movl	-8016160(%rbp), %eax
	addl	$1, %eax
	cltq
	movl	-8016080(%rbp,%rax,4), %eax
	cmpl	%eax, %edx
	je	.L35
.L34:
	movq	-8016152(%rbp), %rax
	movl	(%rax), %eax
	leal	1(%rax), %edx
	movl	-8016160(%rbp), %eax
	addl	$1, %eax
	cltq
	movl	-8016080(%rbp,%rax,4), %eax
	cmpl	%eax, %edx
	je	.L36
	movq	-8016152(%rbp), %rax
	movl	(%rax), %eax
	leal	-1(%rax), %edx
	movl	-8016160(%rbp), %eax
	addl	$1, %eax
	cltq
	movl	-8016080(%rbp,%rax,4), %eax
	cmpl	%eax, %edx
	jne	.L37
.L36:
	movq	-8016152(%rbp), %rax
	movl	4(%rax), %edx
	movl	-8016160(%rbp), %eax
	addl	$1, %eax
	cltq
	movl	-8016128(%rbp,%rax,4), %eax
	cmpl	%eax, %edx
	je	.L35
.L37:
	movq	-8016152(%rbp), %rax
	movl	4(%rax), %eax
	leal	1(%rax), %edx
	movq	-8016152(%rbp), %rax
	movl	(%rax), %eax
	movslq	%eax, %rcx
	movslq	%edx, %rax
	imulq	$1002, %rax, %rax
	addq	%rcx, %rax
	movl	-4016032(%rbp,%rax,4), %eax
	testl	%eax, %eax
	jne	.L38
	movq	-8016152(%rbp), %rax
	movl	4(%rax), %eax
	leal	1(%rax), %edx
	movq	-8016152(%rbp), %rax
	movl	(%rax), %eax
	movslq	%eax, %rcx
	movslq	%edx, %rax
	imulq	$1002, %rax, %rax
	addq	%rcx, %rax
	movl	$1, -4016032(%rbp,%rax,4)
	movq	-8016152(%rbp), %rax
	movl	8(%rax), %eax
	leal	1(%rax), %ecx
	movq	-8016152(%rbp), %rax
	movl	(%rax), %edx
	movq	-8016152(%rbp), %rax
	movl	4(%rax), %eax
	leal	1(%rax), %esi
	movq	-8016144(%rbp), %rax
	movq	%rax, %rdi
	call	push
	movq	%rax, -8016144(%rbp)
.L38:
	movq	-8016152(%rbp), %rax
	movl	4(%rax), %eax
	leal	-1(%rax), %edx
	movq	-8016152(%rbp), %rax
	movl	(%rax), %eax
	movslq	%eax, %rcx
	movslq	%edx, %rax
	imulq	$1002, %rax, %rax
	addq	%rcx, %rax
	movl	-4016032(%rbp,%rax,4), %eax
	testl	%eax, %eax
	jne	.L39
	movq	-8016152(%rbp), %rax
	movl	4(%rax), %eax
	leal	-1(%rax), %edx
	movq	-8016152(%rbp), %rax
	movl	(%rax), %eax
	movslq	%eax, %rcx
	movslq	%edx, %rax
	imulq	$1002, %rax, %rax
	addq	%rcx, %rax
	movl	$1, -4016032(%rbp,%rax,4)
	movq	-8016152(%rbp), %rax
	movl	8(%rax), %eax
	leal	1(%rax), %ecx
	movq	-8016152(%rbp), %rax
	movl	(%rax), %edx
	movq	-8016152(%rbp), %rax
	movl	4(%rax), %eax
	leal	-1(%rax), %esi
	movq	-8016144(%rbp), %rax
	movq	%rax, %rdi
	call	push
	movq	%rax, -8016144(%rbp)
.L39:
	movq	-8016152(%rbp), %rax
	movl	4(%rax), %edx
	movq	-8016152(%rbp), %rax
	movl	(%rax), %eax
	subl	$1, %eax
	movslq	%eax, %rcx
	movslq	%edx, %rax
	imulq	$1002, %rax, %rax
	addq	%rcx, %rax
	movl	-4016032(%rbp,%rax,4), %eax
	testl	%eax, %eax
	jne	.L40
	movq	-8016152(%rbp), %rax
	movl	4(%rax), %edx
	movq	-8016152(%rbp), %rax
	movl	(%rax), %eax
	subl	$1, %eax
	movslq	%eax, %rcx
	movslq	%edx, %rax
	imulq	$1002, %rax, %rax
	addq	%rcx, %rax
	movl	$1, -4016032(%rbp,%rax,4)
	movq	-8016152(%rbp), %rax
	movl	8(%rax), %eax
	leal	1(%rax), %ecx
	movq	-8016152(%rbp), %rax
	movl	(%rax), %eax
	leal	-1(%rax), %edx
	movq	-8016152(%rbp), %rax
	movl	4(%rax), %esi
	movq	-8016144(%rbp), %rax
	movq	%rax, %rdi
	call	push
	movq	%rax, -8016144(%rbp)
.L40:
	movq	-8016152(%rbp), %rax
	movl	4(%rax), %edx
	movq	-8016152(%rbp), %rax
	movl	(%rax), %eax
	addl	$1, %eax
	movslq	%eax, %rcx
	movslq	%edx, %rax
	imulq	$1002, %rax, %rax
	addq	%rcx, %rax
	movl	-4016032(%rbp,%rax,4), %eax
	testl	%eax, %eax
	jne	.L41
	movq	-8016152(%rbp), %rax
	movl	4(%rax), %edx
	movq	-8016152(%rbp), %rax
	movl	(%rax), %eax
	addl	$1, %eax
	movslq	%eax, %rcx
	movslq	%edx, %rax
	imulq	$1002, %rax, %rax
	addq	%rcx, %rax
	movl	$1, -4016032(%rbp,%rax,4)
	movq	-8016152(%rbp), %rax
	movl	8(%rax), %eax
	leal	1(%rax), %ecx
	movq	-8016152(%rbp), %rax
	movl	(%rax), %eax
	leal	1(%rax), %edx
	movq	-8016152(%rbp), %rax
	movl	4(%rax), %esi
	movq	-8016144(%rbp), %rax
	movq	%rax, %rdi
	call	push
	movq	%rax, -8016144(%rbp)
.L41:
	movq	-8016152(%rbp), %rax
	movq	%rax, %rdi
	call	delhead
	movq	%rax, -8016152(%rbp)
.L32:
	cmpq	$0, -8016152(%rbp)
	jne	.L42
.L35:
	cmpq	$0, -8016152(%rbp)
	je	.L43
	movq	-8016152(%rbp), %rax
	movl	8(%rax), %eax
	addl	$1, %eax
	movl	%eax, -8016156(%rbp)
	movq	-8016152(%rbp), %rax
	movq	%rax, %rdi
	call	allfree
	jmp	.L49
.L43:
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	movl	$0, %eax
	jmp	.L47
.L49:
	addl	$1, -8016160(%rbp)
.L27:
	movl	-8016172(%rbp), %eax
	cmpl	%eax, -8016160(%rbp)
	jl	.L46
	movl	-8016156(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
.L47:
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L48
	call	__stack_chk_fail@PLT
.L48:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE10:
	.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	allfree
	.type	allfree, @function
allfree:
.LFB6:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$48, %rsp
	movq	%rdi, -40(%rbp)
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movq	-40(%rbp), %rax
	movq	%rax, -32(%rbp)
	cmpq	$0, -40(%rbp)
	je	.L7
	movq	-40(%rbp), %rax
	movq	16(%rax), %rax
	movq	%rax, -24(%rbp)
	jmp	.L4
.L5:
	movq	-32(%rbp), %rax
	movq	%rax, %rdi
	call	free@PLT
	movq	-24(%rbp), %rax
	movq	%rax, -32(%rbp)
	movq	-24(%rbp), %rax
	movq	16(%rax), %rax
	movq	%rax, -24(%rbp)
.L4:
	movq	-24(%rbp), %rax
	testq	%rax, %rax
	jne	.L5
	movq	-32(%rbp), %rax
	movq	%rax, %rdi
	call	free@PLT
	jmp	.L1
.L7:
	nop
.L1:
	movq	-8(%rbp), %rax
	subq	%fs:40, %rax
	je	.L6
	call	__stack_chk_fail@PLT
.L6:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	allfree, .-allfree
	.globl	push
	.type	push, @function
push:
.LFB7:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$32, %rsp
	movq	%rdi, -8(%rbp)
	movl	%esi, -12(%rbp)
	movl	%edx, -16(%rbp)
	movl	%ecx, -20(%rbp)
	cmpq	$0, -8(%rbp)
	jne	.L9
	movl	$0, %eax
	jmp	.L10
.L9:
	movl	$24, %edi
	call	malloc@PLT
	movq	%rax, %rdx
	movq	-8(%rbp), %rax
	movq	%rdx, 16(%rax)
	movq	-8(%rbp), %rax
	movq	16(%rax), %rax
	movq	$0, 16(%rax)
	movq	-8(%rbp), %rax
	movq	16(%rax), %rax
	movl	-20(%rbp), %edx
	movl	%edx, 8(%rax)
	movq	-8(%rbp), %rax
	movq	16(%rax), %rax
	movl	-16(%rbp), %edx
	movl	%edx, (%rax)
	movq	-8(%rbp), %rax
	movq	16(%rax), %rax
	movl	-12(%rbp), %edx
	movl	%edx, 4(%rax)
	movq	-8(%rbp), %rax
	movq	16(%rax), %rax
.L10:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.size	push, .-push
	.globl	Queue
	.type	Queue, @function
Queue:
.LFB8:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$32, %rsp
	movl	%edi, -20(%rbp)
	movl	%esi, -24(%rbp)
	movl	%edx, -28(%rbp)
	movl	$24, %edi
	call	malloc@PLT
	movq	%rax, -8(%rbp)
	movq	-8(%rbp), %rax
	movq	$0, 16(%rax)
	movq	-8(%rbp), %rax
	movl	-24(%rbp), %edx
	movl	%edx, (%rax)
	movq	-8(%rbp), %rax
	movl	-20(%rbp), %edx
	movl	%edx, 4(%rax)
	movq	-8(%rbp), %rax
	movl	-28(%rbp), %edx
	movl	%edx, 8(%rax)
	movq	-8(%rbp), %rax
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE8:
	.size	Queue, .-Queue
	.globl	delhead
	.type	delhead, @function
delhead:
.LFB9:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$32, %rsp
	movq	%rdi, -24(%rbp)
	cmpq	$0, -24(%rbp)
	jne	.L14
	movl	$0, %eax
	jmp	.L15
.L14:
	movq	-24(%rbp), %rax
	movq	16(%rax), %rax
	movq	%rax, -8(%rbp)
	movq	-24(%rbp), %rax
	movq	%rax, %rdi
	call	free@PLT
	movq	-8(%rbp), %rax
.L15:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE9:
	.size	delhead, .-delhead
	.section	.rodata
.LC0:
	.string	"%d %d %d"
.LC1:
	.string	"Incorrect Data"
.LC2:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB10:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	leaq	-8015872(%rsp), %r11
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	subq	$320, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	$1001, %edi
	call	malloc@PLT
	movq	%rax, -8016136(%rbp)
	movq	-8016136(%rbp), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	gets@PLT
	leaq	-8016172(%rbp), %rsi
	leaq	-8016180(%rbp), %rcx
	leaq	-8016176(%rbp), %rdx
	movq	-8016136(%rbp), %rax
	movq	%rsi, %r8
	leaq	.LC0(%rip), %rsi
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_sscanf@PLT
	movl	$0, -8016168(%rbp)
	jmp	.L17
.L22:
	movq	-8016136(%rbp), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	gets@PLT
	movl	$0, -8016164(%rbp)
	jmp	.L18
.L21:
	movl	-8016164(%rbp), %eax
	movslq	%eax, %rdx
	movq	-8016136(%rbp), %rax
	addq	%rdx, %rax
	movzbl	(%rax), %eax
	cmpb	$88, %al
	sete	%al
	movzbl	%al, %eax
	movl	-8016164(%rbp), %edx
	movslq	%edx, %rcx
	movl	-8016168(%rbp), %edx
	movslq	%edx, %rdx
	imulq	$1000, %rdx, %rdx
	addq	%rcx, %rdx
	movl	%eax, -8016032(%rbp,%rdx,4)
	movl	-8016164(%rbp), %eax
	movslq	%eax, %rdx
	movq	-8016136(%rbp), %rax
	addq	%rdx, %rax
	movzbl	(%rax), %eax
	cmpb	$48, %al
	jle	.L19
	movl	-8016164(%rbp), %eax
	movslq	%eax, %rdx
	movq	-8016136(%rbp), %rax
	addq	%rdx, %rax
	movzbl	(%rax), %eax
	cmpb	$57, %al
	jg	.L19
	movl	-8016164(%rbp), %eax
	movslq	%eax, %rdx
	movq	-8016136(%rbp), %rax
	addq	%rdx, %rax
	movzbl	(%rax), %eax
	movsbl	%al, %eax
	leal	-48(%rax), %ecx
	movl	-8016168(%rbp), %eax
	leal	1(%rax), %edx
	movslq	%ecx, %rax
	movl	%edx, -8016128(%rbp,%rax,4)
	movl	-8016164(%rbp), %eax
	movslq	%eax, %rdx
	movq	-8016136(%rbp), %rax
	addq	%rdx, %rax
	movzbl	(%rax), %eax
	movsbl	%al, %eax
	leal	-48(%rax), %ecx
	movl	-8016164(%rbp), %eax
	leal	1(%rax), %edx
	movslq	%ecx, %rax
	movl	%edx, -8016080(%rbp,%rax,4)
.L19:
	movl	-8016164(%rbp), %eax
	movslq	%eax, %rdx
	movq	-8016136(%rbp), %rax
	addq	%rdx, %rax
	movzbl	(%rax), %eax
	cmpb	$83, %al
	jne	.L20
	movl	-8016168(%rbp), %eax
	addl	$1, %eax
	movl	%eax, -8016128(%rbp)
	movl	-8016164(%rbp), %eax
	addl	$1, %eax
	movl	%eax, -8016080(%rbp)
.L20:
	addl	$1, -8016164(%rbp)
.L18:
	movl	-8016180(%rbp), %eax
	cmpl	%eax, -8016164(%rbp)
	jl	.L21
	addl	$1, -8016168(%rbp)
.L17:
	movl	-8016176(%rbp), %eax
	cmpl	%eax, -8016168(%rbp)
	jl	.L22
	movl	$0, -8016168(%rbp)
	jmp	.L23
.L24:
	movl	-8016168(%rbp), %eax
	cltq
	imulq	$4008, %rax, %rax
	addq	%rbp, %rax
	subq	$4016032, %rax
	movl	$1, (%rax)
	movl	-8016180(%rbp), %eax
	addl	$1, %eax
	movslq	%eax, %rdx
	movl	-8016168(%rbp), %eax
	cltq
	imulq	$1002, %rax, %rax
	addq	%rdx, %rax
	movl	$1, -4016032(%rbp,%rax,4)
	addl	$1, -8016168(%rbp)
.L23:
	movl	-8016176(%rbp), %eax
	addl	$1, %eax
	cmpl	%eax, -8016168(%rbp)
	jle	.L24
	movl	$0, -8016164(%rbp)
	jmp	.L25
.L26:
	movl	-8016164(%rbp), %eax
	cltq
	movl	$1, -4016032(%rbp,%rax,4)
	movl	-8016176(%rbp), %eax
	leal	1(%rax), %edx
	movl	-8016164(%rbp), %eax
	movslq	%eax, %rcx
	movslq	%edx, %rax
	imulq	$1002, %rax, %rax
	addq	%rcx, %rax
	movl	$1, -4016032(%rbp,%rax,4)
	addl	$1, -8016164(%rbp)
.L25:
	movl	-8016180(%rbp), %eax
	addl	$1, %eax
	cmpl	%eax, -8016164(%rbp)
	jle	.L26
	movl	$0, -8016156(%rbp)
	movl	$0, -8016160(%rbp)
	jmp	.L27
.L46:
	movl	-8016160(%rbp), %eax
	cltq
	movl	-8016080(%rbp,%rax,4), %ecx
	movl	-8016160(%rbp), %eax
	cltq
	movl	-8016128(%rbp,%rax,4), %eax
	movl	-8016156(%rbp), %edx
	movl	%ecx, %esi
	movl	%eax, %edi
	call	Queue
	movq	%rax, -8016152(%rbp)
	movq	-8016152(%rbp), %rax
	movq	%rax, -8016144(%rbp)
	movl	$0, -8016168(%rbp)
	jmp	.L28
.L31:
	movl	$0, -8016164(%rbp)
	jmp	.L29
.L30:
	movl	-8016168(%rbp), %eax
	leal	1(%rax), %edx
	movl	-8016164(%rbp), %eax
	leal	1(%rax), %ecx
	movl	-8016164(%rbp), %eax
	movslq	%eax, %rsi
	movl	-8016168(%rbp), %eax
	cltq
	imulq	$1000, %rax, %rax
	addq	%rsi, %rax
	movl	-8016032(%rbp,%rax,4), %eax
	movslq	%ecx, %rcx
	movslq	%edx, %rdx
	imulq	$1002, %rdx, %rdx
	addq	%rcx, %rdx
	movl	%eax, -4016032(%rbp,%rdx,4)
	addl	$1, -8016164(%rbp)
.L29:
	movl	-8016180(%rbp), %eax
	cmpl	%eax, -8016164(%rbp)
	jl	.L30
	addl	$1, -8016168(%rbp)
.L28:
	movl	-8016176(%rbp), %eax
	cmpl	%eax, -8016168(%rbp)
	jl	.L31
	jmp	.L32
.L42:
	movq	-8016152(%rbp), %rax
	movl	4(%rax), %eax
	leal	1(%rax), %edx
	movl	-8016160(%rbp), %eax
	addl	$1, %eax
	cltq
	movl	-8016128(%rbp,%rax,4), %eax
	cmpl	%eax, %edx
	je	.L33
	movq	-8016152(%rbp), %rax
	movl	4(%rax), %eax
	leal	-1(%rax), %edx
	movl	-8016160(%rbp), %eax
	addl	$1, %eax
	cltq
	movl	-8016128(%rbp,%rax,4), %eax
	cmpl	%eax, %edx
	jne	.L34
.L33:
	movq	-8016152(%rbp), %rax
	movl	(%rax), %edx
	movl	-8016160(%rbp), %eax
	addl	$1, %eax
	cltq
	movl	-8016080(%rbp,%rax,4), %eax
	cmpl	%eax, %edx
	je	.L35
.L34:
	movq	-8016152(%rbp), %rax
	movl	(%rax), %eax
	leal	1(%rax), %edx
	movl	-8016160(%rbp), %eax
	addl	$1, %eax
	cltq
	movl	-8016080(%rbp,%rax,4), %eax
	cmpl	%eax, %edx
	je	.L36
	movq	-8016152(%rbp), %rax
	movl	(%rax), %eax
	leal	-1(%rax), %edx
	movl	-8016160(%rbp), %eax
	addl	$1, %eax
	cltq
	movl	-8016080(%rbp,%rax,4), %eax
	cmpl	%eax, %edx
	jne	.L37
.L36:
	movq	-8016152(%rbp), %rax
	movl	4(%rax), %edx
	movl	-8016160(%rbp), %eax
	addl	$1, %eax
	cltq
	movl	-8016128(%rbp,%rax,4), %eax
	cmpl	%eax, %edx
	je	.L35
.L37:
	movq	-8016152(%rbp), %rax
	movl	4(%rax), %eax
	leal	1(%rax), %edx
	movq	-8016152(%rbp), %rax
	movl	(%rax), %eax
	movslq	%eax, %rcx
	movslq	%edx, %rax
	imulq	$1002, %rax, %rax
	addq	%rcx, %rax
	movl	-4016032(%rbp,%rax,4), %eax
	testl	%eax, %eax
	jne	.L38
	movq	-8016152(%rbp), %rax
	movl	4(%rax), %eax
	leal	1(%rax), %edx
	movq	-8016152(%rbp), %rax
	movl	(%rax), %eax
	movslq	%eax, %rcx
	movslq	%edx, %rax
	imulq	$1002, %rax, %rax
	addq	%rcx, %rax
	movl	$1, -4016032(%rbp,%rax,4)
	movq	-8016152(%rbp), %rax
	movl	8(%rax), %eax
	leal	1(%rax), %ecx
	movq	-8016152(%rbp), %rax
	movl	(%rax), %edx
	movq	-8016152(%rbp), %rax
	movl	4(%rax), %eax
	leal	1(%rax), %esi
	movq	-8016144(%rbp), %rax
	movq	%rax, %rdi
	call	push
	movq	%rax, -8016144(%rbp)
.L38:
	movq	-8016152(%rbp), %rax
	movl	4(%rax), %eax
	leal	-1(%rax), %edx
	movq	-8016152(%rbp), %rax
	movl	(%rax), %eax
	movslq	%eax, %rcx
	movslq	%edx, %rax
	imulq	$1002, %rax, %rax
	addq	%rcx, %rax
	movl	-4016032(%rbp,%rax,4), %eax
	testl	%eax, %eax
	jne	.L39
	movq	-8016152(%rbp), %rax
	movl	4(%rax), %eax
	leal	-1(%rax), %edx
	movq	-8016152(%rbp), %rax
	movl	(%rax), %eax
	movslq	%eax, %rcx
	movslq	%edx, %rax
	imulq	$1002, %rax, %rax
	addq	%rcx, %rax
	movl	$1, -4016032(%rbp,%rax,4)
	movq	-8016152(%rbp), %rax
	movl	8(%rax), %eax
	leal	1(%rax), %ecx
	movq	-8016152(%rbp), %rax
	movl	(%rax), %edx
	movq	-8016152(%rbp), %rax
	movl	4(%rax), %eax
	leal	-1(%rax), %esi
	movq	-8016144(%rbp), %rax
	movq	%rax, %rdi
	call	push
	movq	%rax, -8016144(%rbp)
.L39:
	movq	-8016152(%rbp), %rax
	movl	4(%rax), %edx
	movq	-8016152(%rbp), %rax
	movl	(%rax), %eax
	subl	$1, %eax
	movslq	%eax, %rcx
	movslq	%edx, %rax
	imulq	$1002, %rax, %rax
	addq	%rcx, %rax
	movl	-4016032(%rbp,%rax,4), %eax
	testl	%eax, %eax
	jne	.L40
	movq	-8016152(%rbp), %rax
	movl	4(%rax), %edx
	movq	-8016152(%rbp), %rax
	movl	(%rax), %eax
	subl	$1, %eax
	movslq	%eax, %rcx
	movslq	%edx, %rax
	imulq	$1002, %rax, %rax
	addq	%rcx, %rax
	movl	$1, -4016032(%rbp,%rax,4)
	movq	-8016152(%rbp), %rax
	movl	8(%rax), %eax
	leal	1(%rax), %ecx
	movq	-8016152(%rbp), %rax
	movl	(%rax), %eax
	leal	-1(%rax), %edx
	movq	-8016152(%rbp), %rax
	movl	4(%rax), %esi
	movq	-8016144(%rbp), %rax
	movq	%rax, %rdi
	call	push
	movq	%rax, -8016144(%rbp)
.L40:
	movq	-8016152(%rbp), %rax
	movl	4(%rax), %edx
	movq	-8016152(%rbp), %rax
	movl	(%rax), %eax
	addl	$1, %eax
	movslq	%eax, %rcx
	movslq	%edx, %rax
	imulq	$1002, %rax, %rax
	addq	%rcx, %rax
	movl	-4016032(%rbp,%rax,4), %eax
	testl	%eax, %eax
	jne	.L41
	movq	-8016152(%rbp), %rax
	movl	4(%rax), %edx
	movq	-8016152(%rbp), %rax
	movl	(%rax), %eax
	addl	$1, %eax
	movslq	%eax, %rcx
	movslq	%edx, %rax
	imulq	$1002, %rax, %rax
	addq	%rcx, %rax
	movl	$1, -4016032(%rbp,%rax,4)
	movq	-8016152(%rbp), %rax
	movl	8(%rax), %eax
	leal	1(%rax), %ecx
	movq	-8016152(%rbp), %rax
	movl	(%rax), %eax
	leal	1(%rax), %edx
	movq	-8016152(%rbp), %rax
	movl	4(%rax), %esi
	movq	-8016144(%rbp), %rax
	movq	%rax, %rdi
	call	push
	movq	%rax, -8016144(%rbp)
.L41:
	movq	-8016152(%rbp), %rax
	movq	%rax, %rdi
	call	delhead
	movq	%rax, -8016152(%rbp)
.L32:
	cmpq	$0, -8016152(%rbp)
	jne	.L42
.L35:
	cmpq	$0, -8016152(%rbp)
	je	.L43
	movq	-8016152(%rbp), %rax
	movl	8(%rax), %eax
	addl	$1, %eax
	movl	%eax, -8016156(%rbp)
	movq	-8016152(%rbp), %rax
	movq	%rax, %rdi
	call	allfree
	jmp	.L49
.L43:
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	movl	$0, %eax
	jmp	.L47
.L49:
	addl	$1, -8016160(%rbp)
.L27:
	movl	-8016172(%rbp), %eax
	cmpl	%eax, -8016160(%rbp)
	jl	.L46
	movl	-8016156(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
.L47:
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L48
	call	__stack_chk_fail@PLT
.L48:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE10:
	.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:
