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 UNKNOWN_ID -1
#define DEFAULT_VARR_SIZE 8
#define EMPTY_QUEUE(q) (q->size == 0)
#define FULL_QUEUE(q) (q->size == q->max)

typedef struct { int head, tail, size, max, *arr; } queue_t;
typedef struct { int size, i, *arr; } varr_t;

static queue_t *new_queue(int size) {
  queue_t *q;
  int i;

  q = (queue_t *) malloc(sizeof(queue_t));
  q->head = q->tail = q->size = 0;
  q->max = size;
  q->arr = (int *) malloc(sizeof(int) * size);
  for (i = 0; i < size; ++i) q->arr[i] = UNKNOWN_ID;
  return q;
}

static void free_queue(queue_t *q) {
  free(q->arr);
  free(q);
}

static void enqueue(queue_t *q, int n) {
  if (FULL_QUEUE(q)) return;
  q->arr[q->tail] = n;
  q->tail = (q->tail + 1) % q->max;
  q->size--;
}

static int dequeue(queue_t *q) {
  int n;

  if (EMPTY_QUEUE(q)) return UNKNOWN_ID;
  n = q->arr[q->head];
  q->arr[q->head] = UNKNOWN_ID;
  q->head = (q->head + 1) % q->max;
  q->size++;
  return n;
}

static void topological_sort(int size, int *vt, int *ig, varr_t *ts, varr_t *g) {
  int i, j, m, n;
  queue_t *q;

  for (i = 0; i < size; ++i) {
    if (vt[i] == 0 && ig[i] == 0) {
      q = new_queue(size);
      enqueue(q, i);
      while (!EMPTY_QUEUE(q)) {
        m = dequeue(q);
        vt[m] = 1;
        ts->arr[ts->i++] = m;
        for (j = 0; j < g[m].i; ++j) {
          n = g[m].arr[j];
          if (vt[n] == 1) continue;
          if (--ig[n] == 0) enqueue(q, n);
        }
      }
      free_queue(q);
    }
  }
}

int main(int argc, char **argv) {
  int v, e, i, k, l, *vt, *ig; // visited, in-degree
  varr_t ts, *g; // topological sorted array, graph

  scanf("%d %d", &v, &e);
  vt = (int *) malloc(sizeof(int) * v);
  ig = (int *) malloc(sizeof(int) * v);
  ts.size = v;
  ts.i = 0;
  ts.arr = (int *) malloc(sizeof(int) * ts.size);
  g = (varr_t *) malloc(sizeof(varr_t) * v);
  for (i = 0; i < v; ++i) {
    vt[i] = ig[i] = 0;
    g[i].size = DEFAULT_VARR_SIZE;
    g[i].i = 0;
    g[i].arr = (int *) malloc(sizeof(int) * g[i].size);
  }
  for (i = 0; i < e; ++i) {
    scanf("%d %d", &k, &l);
    if (g[k].i == g[k].size) {
      g[k].size *= 2;
      g[k].arr = (int *) realloc(g[k].arr, sizeof(int) * g[k].size);
    }
    g[k].arr[g[k].i++] = l;
    ig[l]++;
  }
  topological_sort(v, vt, ig, &ts, g);
  for (i = 0; i < ts.i; ++i) printf("%d\n", ts.arr[i]);
  free(vt); free(ig); free(ts.arr);
  for (i = 0; i < v; ++i) free(g[i].arr);
}
```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.type	new_queue, @function
new_queue:
.LFB6:
	.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	$24, %edi
	call	malloc@PLT
	movq	%rax, -8(%rbp)
	movq	-8(%rbp), %rax
	movl	$0, 8(%rax)
	movq	-8(%rbp), %rax
	movl	8(%rax), %edx
	movq	-8(%rbp), %rax
	movl	%edx, 4(%rax)
	movq	-8(%rbp), %rax
	movl	4(%rax), %edx
	movq	-8(%rbp), %rax
	movl	%edx, (%rax)
	movq	-8(%rbp), %rax
	movl	-20(%rbp), %edx
	movl	%edx, 12(%rax)
	movl	-20(%rbp), %eax
	cltq
	salq	$2, %rax
	movq	%rax, %rdi
	call	malloc@PLT
	movq	%rax, %rdx
	movq	-8(%rbp), %rax
	movq	%rdx, 16(%rax)
	movl	$0, -12(%rbp)
	jmp	.L2
.L3:
	movq	-8(%rbp), %rax
	movq	16(%rax), %rdx
	movl	-12(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rdx, %rax
	movl	$-1, (%rax)
	addl	$1, -12(%rbp)
.L2:
	movl	-12(%rbp), %eax
	cmpl	-20(%rbp), %eax
	jl	.L3
	movq	-8(%rbp), %rax
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	new_queue, .-new_queue
	.type	free_queue, @function
free_queue:
.LFB7:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$16, %rsp
	movq	%rdi, -8(%rbp)
	movq	-8(%rbp), %rax
	movq	16(%rax), %rax
	movq	%rax, %rdi
	call	free@PLT
	movq	-8(%rbp), %rax
	movq	%rax, %rdi
	call	free@PLT
	nop
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.size	free_queue, .-free_queue
	.type	enqueue, @function
enqueue:
.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, -8(%rbp)
	movl	%esi, -12(%rbp)
	movq	-8(%rbp), %rax
	movl	8(%rax), %edx
	movq	-8(%rbp), %rax
	movl	12(%rax), %eax
	cmpl	%eax, %edx
	je	.L9
	movq	-8(%rbp), %rax
	movq	16(%rax), %rdx
	movq	-8(%rbp), %rax
	movl	4(%rax), %eax
	cltq
	salq	$2, %rax
	addq	%rax, %rdx
	movl	-12(%rbp), %eax
	movl	%eax, (%rdx)
	movq	-8(%rbp), %rax
	movl	4(%rax), %eax
	leal	1(%rax), %edx
	movq	-8(%rbp), %rax
	movl	12(%rax), %ecx
	movl	%edx, %eax
	cltd
	idivl	%ecx
	movq	-8(%rbp), %rax
	movl	%edx, 4(%rax)
	movq	-8(%rbp), %rax
	movl	8(%rax), %eax
	leal	-1(%rax), %edx
	movq	-8(%rbp), %rax
	movl	%edx, 8(%rax)
	jmp	.L6
.L9:
	nop
.L6:
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE8:
	.size	enqueue, .-enqueue
	.type	dequeue, @function
dequeue:
.LFB9:
	.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	-24(%rbp), %rax
	movl	8(%rax), %eax
	testl	%eax, %eax
	jne	.L11
	movl	$-1, %eax
	jmp	.L12
.L11:
	movq	-24(%rbp), %rax
	movq	16(%rax), %rdx
	movq	-24(%rbp), %rax
	movl	(%rax), %eax
	cltq
	salq	$2, %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	movl	%eax, -4(%rbp)
	movq	-24(%rbp), %rax
	movq	16(%rax), %rdx
	movq	-24(%rbp), %rax
	movl	(%rax), %eax
	cltq
	salq	$2, %rax
	addq	%rdx, %rax
	movl	$-1, (%rax)
	movq	-24(%rbp), %rax
	movl	(%rax), %eax
	leal	1(%rax), %edx
	movq	-24(%rbp), %rax
	movl	12(%rax), %ecx
	movl	%edx, %eax
	cltd
	idivl	%ecx
	movq	-24(%rbp), %rax
	movl	%edx, (%rax)
	movq	-24(%rbp), %rax
	movl	8(%rax), %eax
	leal	1(%rax), %edx
	movq	-24(%rbp), %rax
	movl	%edx, 8(%rax)
	movl	-4(%rbp), %eax
.L12:
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE9:
	.size	dequeue, .-dequeue
	.type	topological_sort, @function
topological_sort:
.LFB10:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$80, %rsp
	movl	%edi, -36(%rbp)
	movq	%rsi, -48(%rbp)
	movq	%rdx, -56(%rbp)
	movq	%rcx, -64(%rbp)
	movq	%r8, -72(%rbp)
	movl	$0, -24(%rbp)
	jmp	.L14
.L22:
	movl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-48(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	testl	%eax, %eax
	jne	.L15
	movl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-56(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	testl	%eax, %eax
	jne	.L15
	movl	-36(%rbp), %eax
	movl	%eax, %edi
	call	new_queue
	movq	%rax, -8(%rbp)
	movl	-24(%rbp), %edx
	movq	-8(%rbp), %rax
	movl	%edx, %esi
	movq	%rax, %rdi
	call	enqueue
	jmp	.L16
.L21:
	movq	-8(%rbp), %rax
	movq	%rax, %rdi
	call	dequeue
	movl	%eax, -16(%rbp)
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-48(%rbp), %rax
	addq	%rdx, %rax
	movl	$1, (%rax)
	movq	-64(%rbp), %rax
	movq	8(%rax), %rsi
	movq	-64(%rbp), %rax
	movl	4(%rax), %eax
	leal	1(%rax), %ecx
	movq	-64(%rbp), %rdx
	movl	%ecx, 4(%rdx)
	cltq
	salq	$2, %rax
	leaq	(%rsi,%rax), %rdx
	movl	-16(%rbp), %eax
	movl	%eax, (%rdx)
	movl	$0, -20(%rbp)
	jmp	.L17
.L20:
	movl	-16(%rbp), %eax
	cltq
	salq	$4, %rax
	movq	%rax, %rdx
	movq	-72(%rbp), %rax
	addq	%rdx, %rax
	movq	8(%rax), %rdx
	movl	-20(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	movl	%eax, -12(%rbp)
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-48(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	cmpl	$1, %eax
	je	.L23
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-56(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %edx
	subl	$1, %edx
	movl	%edx, (%rax)
	movl	(%rax), %eax
	testl	%eax, %eax
	jne	.L19
	movl	-12(%rbp), %edx
	movq	-8(%rbp), %rax
	movl	%edx, %esi
	movq	%rax, %rdi
	call	enqueue
	jmp	.L19
.L23:
	nop
.L19:
	addl	$1, -20(%rbp)
.L17:
	movl	-16(%rbp), %eax
	cltq
	salq	$4, %rax
	movq	%rax, %rdx
	movq	-72(%rbp), %rax
	addq	%rdx, %rax
	movl	4(%rax), %eax
	cmpl	%eax, -20(%rbp)
	jl	.L20
.L16:
	movq	-8(%rbp), %rax
	movl	8(%rax), %eax
	testl	%eax, %eax
	jne	.L21
	movq	-8(%rbp), %rax
	movq	%rax, %rdi
	call	free_queue
.L15:
	addl	$1, -24(%rbp)
.L14:
	movl	-24(%rbp), %eax
	cmpl	-36(%rbp), %eax
	jl	.L22
	nop
	nop
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE10:
	.size	topological_sort, .-topological_sort
	.section	.rodata
.LC0:
	.string	"%d %d"
.LC1:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB11:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	pushq	%rbx
	subq	$104, %rsp
	.cfi_offset 3, -24
	movl	%edi, -100(%rbp)
	movq	%rsi, -112(%rbp)
	movq	%fs:40, %rax
	movq	%rax, -24(%rbp)
	xorl	%eax, %eax
	leaq	-88(%rbp), %rdx
	leaq	-92(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-92(%rbp), %eax
	cltq
	salq	$2, %rax
	movq	%rax, %rdi
	call	malloc@PLT
	movq	%rax, -72(%rbp)
	movl	-92(%rbp), %eax
	cltq
	salq	$2, %rax
	movq	%rax, %rdi
	call	malloc@PLT
	movq	%rax, -64(%rbp)
	movl	-92(%rbp), %eax
	movl	%eax, -48(%rbp)
	movl	$0, -44(%rbp)
	movl	-48(%rbp), %eax
	cltq
	salq	$2, %rax
	movq	%rax, %rdi
	call	malloc@PLT
	movq	%rax, -40(%rbp)
	movl	-92(%rbp), %eax
	cltq
	salq	$4, %rax
	movq	%rax, %rdi
	call	malloc@PLT
	movq	%rax, -56(%rbp)
	movl	$0, -76(%rbp)
	jmp	.L25
.L26:
	movl	-76(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-64(%rbp), %rax
	addq	%rdx, %rax
	movl	$0, (%rax)
	movl	-76(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	movq	-72(%rbp), %rdx
	addq	%rcx, %rdx
	movl	(%rax), %eax
	movl	%eax, (%rdx)
	movl	-76(%rbp), %eax
	cltq
	salq	$4, %rax
	movq	%rax, %rdx
	movq	-56(%rbp), %rax
	addq	%rdx, %rax
	movl	$8, (%rax)
	movl	-76(%rbp), %eax
	cltq
	salq	$4, %rax
	movq	%rax, %rdx
	movq	-56(%rbp), %rax
	addq	%rdx, %rax
	movl	$0, 4(%rax)
	movl	-76(%rbp), %eax
	cltq
	salq	$4, %rax
	movq	%rax, %rdx
	movq	-56(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	cltq
	salq	$2, %rax
	movl	-76(%rbp), %edx
	movslq	%edx, %rdx
	movq	%rdx, %rcx
	salq	$4, %rcx
	movq	-56(%rbp), %rdx
	leaq	(%rcx,%rdx), %rbx
	movq	%rax, %rdi
	call	malloc@PLT
	movq	%rax, 8(%rbx)
	addl	$1, -76(%rbp)
.L25:
	movl	-92(%rbp), %eax
	cmpl	%eax, -76(%rbp)
	jl	.L26
	movl	$0, -76(%rbp)
	jmp	.L27
.L29:
	leaq	-80(%rbp), %rdx
	leaq	-84(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-84(%rbp), %eax
	cltq
	salq	$4, %rax
	movq	%rax, %rdx
	movq	-56(%rbp), %rax
	addq	%rdx, %rax
	movl	4(%rax), %edx
	movl	-84(%rbp), %eax
	cltq
	salq	$4, %rax
	movq	%rax, %rcx
	movq	-56(%rbp), %rax
	addq	%rcx, %rax
	movl	(%rax), %eax
	cmpl	%eax, %edx
	jne	.L28
	movl	-84(%rbp), %eax
	cltq
	salq	$4, %rax
	movq	%rax, %rdx
	movq	-56(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %edx
	movl	-84(%rbp), %eax
	cltq
	salq	$4, %rax
	movq	%rax, %rcx
	movq	-56(%rbp), %rax
	addq	%rcx, %rax
	addl	%edx, %edx
	movl	%edx, (%rax)
	movl	-84(%rbp), %eax
	cltq
	salq	$4, %rax
	movq	%rax, %rdx
	movq	-56(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movl	-84(%rbp), %eax
	cltq
	salq	$4, %rax
	movq	%rax, %rcx
	movq	-56(%rbp), %rax
	addq	%rcx, %rax
	movq	8(%rax), %rax
	movl	-84(%rbp), %ecx
	movslq	%ecx, %rcx
	movq	%rcx, %rsi
	salq	$4, %rsi
	movq	-56(%rbp), %rcx
	leaq	(%rsi,%rcx), %rbx
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	realloc@PLT
	movq	%rax, 8(%rbx)
.L28:
	movl	-84(%rbp), %eax
	cltq
	salq	$4, %rax
	movq	%rax, %rdx
	movq	-56(%rbp), %rax
	addq	%rdx, %rax
	movq	8(%rax), %rsi
	movl	-84(%rbp), %eax
	cltq
	salq	$4, %rax
	movq	%rax, %rdx
	movq	-56(%rbp), %rax
	addq	%rdx, %rax
	movl	4(%rax), %edx
	leal	1(%rdx), %ecx
	movl	%ecx, 4(%rax)
	movslq	%edx, %rax
	salq	$2, %rax
	leaq	(%rsi,%rax), %rdx
	movl	-80(%rbp), %eax
	movl	%eax, (%rdx)
	movl	-80(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-64(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %edx
	addl	$1, %edx
	movl	%edx, (%rax)
	addl	$1, -76(%rbp)
.L27:
	movl	-88(%rbp), %eax
	cmpl	%eax, -76(%rbp)
	jl	.L29
	movl	-92(%rbp), %eax
	movq	-56(%rbp), %rdi
	leaq	-48(%rbp), %rcx
	movq	-64(%rbp), %rdx
	movq	-72(%rbp), %rsi
	movq	%rdi, %r8
	movl	%eax, %edi
	call	topological_sort
	movl	$0, -76(%rbp)
	jmp	.L30
.L31:
	movq	-40(%rbp), %rdx
	movl	-76(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	addl	$1, -76(%rbp)
.L30:
	movl	-44(%rbp), %eax
	cmpl	%eax, -76(%rbp)
	jl	.L31
	movq	-72(%rbp), %rax
	movq	%rax, %rdi
	call	free@PLT
	movq	-64(%rbp), %rax
	movq	%rax, %rdi
	call	free@PLT
	movq	-40(%rbp), %rax
	movq	%rax, %rdi
	call	free@PLT
	movl	$0, -76(%rbp)
	jmp	.L32
.L33:
	movl	-76(%rbp), %eax
	cltq
	salq	$4, %rax
	movq	%rax, %rdx
	movq	-56(%rbp), %rax
	addq	%rdx, %rax
	movq	8(%rax), %rax
	movq	%rax, %rdi
	call	free@PLT
	addl	$1, -76(%rbp)
.L32:
	movl	-92(%rbp), %eax
	cmpl	%eax, -76(%rbp)
	jl	.L33
	movl	$0, %eax
	movq	-24(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L35
	call	__stack_chk_fail@PLT
.L35:
	movq	-8(%rbp), %rbx
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE11:
	.size	main, .-main
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:
```

Only output the optimized assembly code. Do not include any other text. Do not write any comments in the assembly code. Wrap the assembly code in ```assembly``` tags.
user
	.file	"temp.c"
	.text
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d %d"
.LC2:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB44:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	leaq	.LC0(%rip), %r14
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	movq	%r14, %rdi
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$104, %rsp
	.cfi_def_cfa_offset 160
	movq	%fs:40, %rax
	movq	%rax, 88(%rsp)
	xorl	%eax, %eax
	leaq	76(%rsp), %rdx
	leaq	72(%rsp), %rsi
	call	__isoc99_scanf@PLT
	movslq	72(%rsp), %rbx
	leaq	0(,%rbx,4), %r13
	movq	%rbx, %r15
	salq	$4, %rbx
	movq	%r13, %rdi
	call	malloc@PLT
	movq	%r13, %rdi
	movq	%rax, %rbp
	call	malloc@PLT
	movq	%r13, %rdi
	movq	%rax, %r12
	call	malloc@PLT
	movq	%rbx, %rdi
	movq	%rax, 16(%rsp)
	call	malloc@PLT
	movq	%rax, %rbx
	testl	%r15d, %r15d
	jle	.L2
	xorl	%r15d, %r15d
	.p2align 4,,10
	.p2align 3
.L3:
	movq	.LC1(%rip), %rax
	movl	$32, %edi
	movl	$0, 0(%rbp,%r15)
	movl	$0, (%r12,%r15)
	movq	%rax, (%rbx,%r15,4)
	call	malloc@PLT
	movq	%rax, 8(%rbx,%r15,4)
	addq	$4, %r15
	cmpq	%r15, %r13
	jne	.L3
	movl	76(%rsp), %eax
	testl	%eax, %eax
	jle	.L39
.L21:
	xorl	%r13d, %r13d
	leaq	80(%rsp), %rax
	movq	%rbp, 32(%rsp)
	leaq	84(%rsp), %r15
	movl	%r13d, %ebp
	movq	%rax, %r13
	jmp	.L9
	.p2align 4,,10
	.p2align 3
.L41:
	movq	8(%rdx), %rsi
.L8:
	leal	1(%r8), %eax
	addl	$1, %ebp
	movl	%eax, 4(%rdx)
	movslq	84(%rsp), %rax
	movslq	%r8d, %rdx
	addl	$1, (%r12,%rax,4)
	movl	%eax, (%rsi,%rdx,4)
	cmpl	%ebp, 76(%rsp)
	jle	.L40
.L9:
	movq	%r15, %rdx
	movq	%r13, %rsi
	movq	%r14, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movslq	80(%rsp), %rdx
	salq	$4, %rdx
	addq	%rbx, %rdx
	movl	4(%rdx), %r8d
	cmpl	(%rdx), %r8d
	jne	.L41
	leal	(%r8,%r8), %eax
	movq	8(%rdx), %rdi
	movl	%r8d, 28(%rsp)
	movl	%eax, (%rdx)
	cltq
	leaq	0(,%rax,4), %rsi
	movq	%rdx, 8(%rsp)
	call	realloc@PLT
	movq	8(%rsp), %rdx
	movl	28(%rsp), %r8d
	movq	%rax, %rsi
	movq	%rax, 8(%rdx)
	jmp	.L8
	.p2align 4,,10
	.p2align 3
.L40:
	movl	72(%rsp), %r13d
	movq	32(%rsp), %rbp
	testl	%r13d, %r13d
	jle	.L6
.L5:
	movslq	%r13d, %rax
	movl	$0, 28(%rsp)
	xorl	%r15d, %r15d
	salq	$2, %rax
	movq	%rbx, 32(%rsp)
	movq	%rax, 40(%rsp)
	movl	%r13d, %eax
	movq	%rax, 8(%rsp)
	salq	$2, %rax
	movq	%rax, 48(%rsp)
	.p2align 4,,10
	.p2align 3
.L18:
	movl	0(%rbp,%r15,4), %edx
	testl	%edx, %edx
	jne	.L13
	movl	(%r12,%r15,4), %r14d
	testl	%r14d, %r14d
	je	.L42
.L13:
	addq	$1, %r15
	cmpq	%r15, 8(%rsp)
	jne	.L18
	movl	28(%rsp), %eax
	movq	32(%rsp), %rbx
	testl	%eax, %eax
	jle	.L6
	movq	16(%rsp), %rsi
	subl	$1, %eax
	leaq	.LC2(%rip), %r13
	movq	%rsi, %r15
	leaq	4(%rsi,%rax,4), %r14
	.p2align 4,,10
	.p2align 3
.L19:
	movl	(%r15), %edx
	movq	%r13, %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	addq	$4, %r15
	call	__printf_chk@PLT
	cmpq	%r14, %r15
	jne	.L19
.L6:
	movq	%rbp, %rdi
	call	free@PLT
	movq	%r12, %rdi
	call	free@PLT
	movq	16(%rsp), %rdi
	call	free@PLT
	movl	72(%rsp), %eax
	testl	%eax, %eax
	jle	.L12
	subl	$1, %eax
	leaq	8(%rbx), %rbp
	salq	$4, %rax
	leaq	24(%rbx,%rax), %rbx
	.p2align 4,,10
	.p2align 3
.L20:
	movq	0(%rbp), %rdi
	addq	$16, %rbp
	call	free@PLT
	cmpq	%rbx, %rbp
	jne	.L20
.L12:
	movq	88(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L43
	addq	$104, %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
.L42:
	.cfi_restore_state
	movl	$24, %edi
	call	malloc@PLT
	movq	40(%rsp), %rdi
	movl	$0, (%rax)
	movq	%rax, %rbx
	movl	%r13d, 12(%rax)
	call	malloc@PLT
	movq	48(%rsp), %rdx
	movl	$255, %esi
	movq	%rax, 16(%rbx)
	movq	%rax, %rdi
	call	memset@PLT
	movl	28(%rsp), %r10d
	movq	%r15, 56(%rsp)
	orl	$-1, %esi
	movl	%r15d, (%rax)
	movq	%rax, %r9
	movl	$1, %eax
	movq	32(%rsp), %r8
	cltd
	addl	$1, %r10d
	idivl	%r13d
	movslq	%r10d, %r10
	movl	%edx, 4(%rbx)
	.p2align 4,,10
	.p2align 3
.L17:
	movslq	%r14d, %rax
	movq	16(%rsp), %rdi
	addl	$1, %esi
	movl	%r10d, %r15d
	leaq	(%r9,%rax,4), %rax
	movl	(%rax), %ecx
	movl	$-1, (%rax)
	leal	1(%r14), %eax
	cltd
	idivl	%r13d
	movl	%ecx, -4(%rdi,%r10,4)
	movslq	%ecx, %rax
	movl	$1, 0(%rbp,%rax,4)
	salq	$4, %rax
	addq	%r8, %rax
	movl	%edx, %r14d
	movl	4(%rax), %edx
	testl	%edx, %edx
	jle	.L14
	movq	8(%rax), %rax
	subl	$1, %edx
	leaq	4(%rax), %rdi
	leaq	(%rdi,%rdx,4), %r11
	jmp	.L16
	.p2align 4,,10
	.p2align 3
.L44:
	addq	$4, %rdi
.L16:
	movslq	(%rax), %rcx
	cmpl	$1, 0(%rbp,%rcx,4)
	movq	%rcx, %rdx
	leaq	0(,%rcx,4), %rax
	je	.L15
	addq	%r12, %rax
	subl	$1, (%rax)
	jne	.L15
	cmpl	%r13d, %esi
	je	.L15
	movslq	4(%rbx), %rcx
	subl	$1, %esi
	movq	%rcx, %rax
	movl	%edx, (%r9,%rcx,4)
	addl	$1, %eax
	cltd
	idivl	%r13d
	movl	%edx, 4(%rbx)
.L15:
	movq	%rdi, %rax
	cmpq	%r11, %rdi
	jne	.L44
.L14:
	addq	$1, %r10
	testl	%esi, %esi
	jne	.L17
	movq	%r9, %rdi
	movl	%r15d, 28(%rsp)
	movq	56(%rsp), %r15
	call	free@PLT
	movq	%rbx, %rdi
	call	free@PLT
	jmp	.L13
.L2:
	cmpl	$0, 76(%rsp)
	jg	.L21
	jmp	.L6
.L39:
	movl	72(%rsp), %r13d
	jmp	.L5
.L43:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE44:
	.size	main, .-main
	.section	.rodata.cst8,"aM",@progbits,8
	.align 8
.LC1:
	.long	8
	.long	0
	.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
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d %d"
.LC2:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB44:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	leaq	.LC0(%rip), %r14
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	movq	%r14, %rdi
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$104, %rsp
	.cfi_def_cfa_offset 160
	movq	%fs:40, %rax
	movq	%rax, 88(%rsp)
	xorl	%eax, %eax
	leaq	76(%rsp), %rdx
	leaq	72(%rsp), %rsi
	call	__isoc99_scanf@PLT
	movslq	72(%rsp), %rbx
	leaq	0(,%rbx,4), %r13
	movq	%rbx, %r15
	salq	$4, %rbx
	movq	%r13, %rdi
	call	malloc@PLT
	movq	%r13, %rdi
	movq	%rax, %rbp
	call	malloc@PLT
	movq	%r13, %rdi
	movq	%rax, %r12
	call	malloc@PLT
	movq	%rbx, %rdi
	movq	%rax, 16(%rsp)
	call	malloc@PLT
	movq	%rax, %rbx
	testl	%r15d, %r15d
	jle	.L2
	xorl	%r15d, %r15d
	.p2align 4,,10
	.p2align 3
.L3:
	movq	.LC1(%rip), %rax
	movl	$32, %edi
	movl	$0, 0(%rbp,%r15)
	movl	$0, (%r12,%r15)
	movq	%rax, (%rbx,%r15,4)
	call	malloc@PLT
	movq	%rax, 8(%rbx,%r15,4)
	addq	$4, %r15
	cmpq	%r15, %r13
	jne	.L3
	movl	76(%rsp), %eax
	testl	%eax, %eax
	jle	.L39
.L21:
	xorl	%r13d, %r13d
	leaq	80(%rsp), %rax
	movq	%rbp, 32(%rsp)
	leaq	84(%rsp), %r15
	movl	%r13d, %ebp
	movq	%rax, %r13
	jmp	.L9
	.p2align 4,,10
	.p2align 3
.L41:
	movq	8(%rdx), %rsi
.L8:
	leal	1(%r8), %eax
	addl	$1, %ebp
	movl	%eax, 4(%rdx)
	movslq	84(%rsp), %rax
	movslq	%r8d, %rdx
	addl	$1, (%r12,%rax,4)
	movl	%eax, (%rsi,%rdx,4)
	cmpl	%ebp, 76(%rsp)
	jle	.L40
.L9:
	movq	%r15, %rdx
	movq	%r13, %rsi
	movq	%r14, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movslq	80(%rsp), %rdx
	salq	$4, %rdx
	addq	%rbx, %rdx
	movl	4(%rdx), %r8d
	cmpl	(%rdx), %r8d
	jne	.L41
	leal	(%r8,%r8), %eax
	movq	8(%rdx), %rdi
	movl	%r8d, 28(%rsp)
	movl	%eax, (%rdx)
	cltq
	leaq	0(,%rax,4), %rsi
	movq	%rdx, 8(%rsp)
	call	realloc@PLT
	movq	8(%rsp), %rdx
	movl	28(%rsp), %r8d
	movq	%rax, %rsi
	movq	%rax, 8(%rdx)
	jmp	.L8
	.p2align 4,,10
	.p2align 3
.L40:
	movl	72(%rsp), %r13d
	movq	32(%rsp), %rbp
	testl	%r13d, %r13d
	jle	.L6
.L5:
	movslq	%r13d, %rax
	movl	$0, 28(%rsp)
	xorl	%r15d, %r15d
	salq	$2, %rax
	movq	%rbx, 32(%rsp)
	movq	%rax, 40(%rsp)
	movl	%r13d, %eax
	movq	%rax, 8(%rsp)
	salq	$2, %rax
	movq	%rax, 48(%rsp)
	.p2align 4,,10
	.p2align 3
.L18:
	movl	0(%rbp,%r15,4), %edx
	testl	%edx, %edx
	jne	.L13
	movl	(%r12,%r15,4), %r14d
	testl	%r14d, %r14d
	je	.L42
.L13:
	addq	$1, %r15
	cmpq	%r15, 8(%rsp)
	jne	.L18
	movl	28(%rsp), %eax
	movq	32(%rsp), %rbx
	testl	%eax, %eax
	jle	.L6
	movq	16(%rsp), %rsi
	subl	$1, %eax
	leaq	.LC2(%rip), %r13
	movq	%rsi, %r15
	leaq	4(%rsi,%rax,4), %r14
	.p2align 4,,10
	.p2align 3
.L19:
	movl	(%r15), %edx
	movq	%r13, %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	addq	$4, %r15
	call	__printf_chk@PLT
	cmpq	%r14, %r15
	jne	.L19
.L6:
	movq	%rbp, %rdi
	call	free@PLT
	movq	%r12, %rdi
	call	free@PLT
	movq	16(%rsp), %rdi
	call	free@PLT
	movl	72(%rsp), %eax
	testl	%eax, %eax
	jle	.L12
	subl	$1, %eax
	leaq	8(%rbx), %rbp
	salq	$4, %rax
	leaq	24(%rbx,%rax), %rbx
	.p2align 4,,10
	.p2align 3
.L20:
	movq	0(%rbp), %rdi
	addq	$16, %rbp
	call	free@PLT
	cmpq	%rbx, %rbp
	jne	.L20
.L12:
	movq	88(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L43
	addq	$104, %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
.L42:
	.cfi_restore_state
	movl	$24, %edi
	call	malloc@PLT
	movq	40(%rsp), %rdi
	movl	$0, (%rax)
	movq	%rax, %rbx
	movl	%r13d, 12(%rax)
	call	malloc@PLT
	movq	48(%rsp), %rdx
	movl	$255, %esi
	movq	%rax, 16(%rbx)
	movq	%rax, %rdi
	call	memset@PLT
	movl	28(%rsp), %r10d
	movq	%r15, 56(%rsp)
	orl	$-1, %esi
	movl	%r15d, (%rax)
	movq	%rax, %r9
	movl	$1, %eax
	movq	32(%rsp), %r8
	cltd
	addl	$1, %r10d
	idivl	%r13d
	movslq	%r10d, %r10
	movl	%edx, 4(%rbx)
	.p2align 4,,10
	.p2align 3
.L17:
	movslq	%r14d, %rax
	movq	16(%rsp), %rdi
	addl	$1, %esi
	movl	%r10d, %r15d
	leaq	(%r9,%rax,4), %rax
	movl	(%rax), %ecx
	movl	$-1, (%rax)
	leal	1(%r14), %eax
	cltd
	idivl	%r13d
	movl	%ecx, -4(%rdi,%r10,4)
	movslq	%ecx, %rax
	movl	$1, 0(%rbp,%rax,4)
	salq	$4, %rax
	addq	%r8, %rax
	movl	%edx, %r14d
	movl	4(%rax), %edx
	testl	%edx, %edx
	jle	.L14
	movq	8(%rax), %rax
	subl	$1, %edx
	leaq	4(%rax), %rdi
	leaq	(%rdi,%rdx,4), %r11
	jmp	.L16
	.p2align 4,,10
	.p2align 3
.L44:
	addq	$4, %rdi
.L16:
	movslq	(%rax), %rcx
	cmpl	$1, 0(%rbp,%rcx,4)
	movq	%rcx, %rdx
	leaq	0(,%rcx,4), %rax
	je	.L15
	addq	%r12, %rax
	subl	$1, (%rax)
	jne	.L15
	cmpl	%r13d, %esi
	je	.L15
	movslq	4(%rbx), %rcx
	subl	$1, %esi
	movq	%rcx, %rax
	movl	%edx, (%r9,%rcx,4)
	addl	$1, %eax
	cltd
	idivl	%r13d
	movl	%edx, 4(%rbx)
.L15:
	movq	%rdi, %rax
	cmpq	%r11, %rdi
	jne	.L44
.L14:
	addq	$1, %r10
	testl	%esi, %esi
	jne	.L17
	movq	%r9, %rdi
	movl	%r15d, 28(%rsp)
	movq	56(%rsp), %r15
	call	free@PLT
	movq	%rbx, %rdi
	call	free@PLT
	jmp	.L13
.L2:
	cmpl	$0, 76(%rsp)
	jg	.L21
	jmp	.L6
.L39:
	movl	72(%rsp), %r13d
	jmp	.L5
.L43:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE44:
	.size	main, .-main
	.section	.rodata.cst8,"aM",@progbits,8
	.align 8
.LC1:
	.long	8
	.long	0
	.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 UNKNOWN_ID -1
#define DEFAULT_VARR_SIZE 8
#define EMPTY_QUEUE(q) (q->size == 0)
#define FULL_QUEUE(q) (q->size == q->max)

typedef struct { int head, tail, size, max, *arr; } queue_t;
typedef struct { int size, i, *arr; } varr_t;

static queue_t *new_queue(int size) {
  queue_t *q;
  int i;

  q = (queue_t *) malloc(sizeof(queue_t));
  q->head = q->tail = q->size = 0;
  q->max = size;
  q->arr = (int *) malloc(sizeof(int) * size);
  for (i = 0; i < size; ++i) q->arr[i] = UNKNOWN_ID;
  return q;
}

static void free_queue(queue_t *q) {
  free(q->arr);
  free(q);
}

static void enqueue(queue_t *q, int n) {
  if (FULL_QUEUE(q)) return;
  q->arr[q->tail] = n;
  q->tail = (q->tail + 1) % q->max;
  q->size--;
}

static int dequeue(queue_t *q) {
  int n;

  if (EMPTY_QUEUE(q)) return UNKNOWN_ID;
  n = q->arr[q->head];
  q->arr[q->head] = UNKNOWN_ID;
  q->head = (q->head + 1) % q->max;
  q->size++;
  return n;
}

static void topological_sort(int size, int *vt, int *ig, varr_t *ts, varr_t *g) {
  int i, j, m, n;
  queue_t *q;

  for (i = 0; i < size; ++i) {
    if (vt[i] == 0 && ig[i] == 0) {
      q = new_queue(size);
      enqueue(q, i);
      while (!EMPTY_QUEUE(q)) {
        m = dequeue(q);
        vt[m] = 1;
        ts->arr[ts->i++] = m;
        for (j = 0; j < g[m].i; ++j) {
          n = g[m].arr[j];
          if (vt[n] == 1) continue;
          if (--ig[n] == 0) enqueue(q, n);
        }
      }
      free_queue(q);
    }
  }
}

int main(int argc, char **argv) {
  int v, e, i, k, l, *vt, *ig; // visited, in-degree
  varr_t ts, *g; // topological sorted array, graph

  scanf("%d %d", &v, &e);
  vt = (int *) malloc(sizeof(int) * v);
  ig = (int *) malloc(sizeof(int) * v);
  ts.size = v;
  ts.i = 0;
  ts.arr = (int *) malloc(sizeof(int) * ts.size);
  g = (varr_t *) malloc(sizeof(varr_t) * v);
  for (i = 0; i < v; ++i) {
    vt[i] = ig[i] = 0;
    g[i].size = DEFAULT_VARR_SIZE;
    g[i].i = 0;
    g[i].arr = (int *) malloc(sizeof(int) * g[i].size);
  }
  for (i = 0; i < e; ++i) {
    scanf("%d %d", &k, &l);
    if (g[k].i == g[k].size) {
      g[k].size *= 2;
      g[k].arr = (int *) realloc(g[k].arr, sizeof(int) * g[k].size);
    }
    g[k].arr[g[k].i++] = l;
    ig[l]++;
  }
  topological_sort(v, vt, ig, &ts, g);
  for (i = 0; i < ts.i; ++i) printf("%d\n", ts.arr[i]);
  free(vt); free(ig); free(ts.arr);
  for (i = 0; i < v; ++i) free(g[i].arr);
}

6 6
0 1
1 2
4 1
3 4
4 5
5 2
 6 6
0 1
1 2
4 1
3 4
4 5
5 0
 6 6
0 2
1 2
3 1
3 4
4 5
5 2
 6 6
0 1
1 2
3 1
3 4
4 5
5 1
 6 6
0 2
1 2
4 1
3 4
1 5
5 0
 6 0
0 1
1 2
4 1
3 4
4 5
5 2
 4 0
1 2
2 3
2 2
5 4
6 4
5 2
 7 0
1 1
1 2
4 1
3 4
4 5
5 2
 3 0
1 1
1 3
4 1
3 4
4 4
5 2
 11 0
1 2
1 3
1 1
5 4
4 4
5 2

0
3
4
1
5
2
 3
4
5
0
1
2
 0
3
1
4
5
2
 0
3
4
5
1
2
 3
4
1
5
0
2
 0
1
2
3
4
5
 0
1
2
3
 0
1
2
3
4
5
6
 0
1
2
 0
1
2
3
4
5
6
7
8
9
10

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 UNKNOWN_ID -1
#define DEFAULT_VARR_SIZE 8
#define EMPTY_QUEUE(q) (q->size == 0)
#define FULL_QUEUE(q) (q->size == q->max)

typedef struct { int head, tail, size, max, *arr; } queue_t;
typedef struct { int size, i, *arr; } varr_t;

static queue_t *new_queue(int size) {
  queue_t *q;
  int i;

  q = (queue_t *) malloc(sizeof(queue_t));
  q->head = q->tail = q->size = 0;
  q->max = size;
  q->arr = (int *) malloc(sizeof(int) * size);
  for (i = 0; i < size; ++i) q->arr[i] = UNKNOWN_ID;
  return q;
}

static void free_queue(queue_t *q) {
  free(q->arr);
  free(q);
}

static void enqueue(queue_t *q, int n) {
  if (FULL_QUEUE(q)) return;
  q->arr[q->tail] = n;
  q->tail = (q->tail + 1) % q->max;
  q->size--;
}

static int dequeue(queue_t *q) {
  int n;

  if (EMPTY_QUEUE(q)) return UNKNOWN_ID;
  n = q->arr[q->head];
  q->arr[q->head] = UNKNOWN_ID;
  q->head = (q->head + 1) % q->max;
  q->size++;
  return n;
}

static void topological_sort(int size, int *vt, int *ig, varr_t *ts, varr_t *g) {
  int i, j, m, n;
  queue_t *q;

  for (i = 0; i < size; ++i) {
    if (vt[i] == 0 && ig[i] == 0) {
      q = new_queue(size);
      enqueue(q, i);
      while (!EMPTY_QUEUE(q)) {
        m = dequeue(q);
        vt[m] = 1;
        ts->arr[ts->i++] = m;
        for (j = 0; j < g[m].i; ++j) {
          n = g[m].arr[j];
          if (vt[n] == 1) continue;
          if (--ig[n] == 0) enqueue(q, n);
        }
      }
      free_queue(q);
    }
  }
}

int main(int argc, char **argv) {
  int v, e, i, k, l, *vt, *ig; // visited, in-degree
  varr_t ts, *g; // topological sorted array, graph

  scanf("%d %d", &v, &e);
  vt = (int *) malloc(sizeof(int) * v);
  ig = (int *) malloc(sizeof(int) * v);
  ts.size = v;
  ts.i = 0;
  ts.arr = (int *) malloc(sizeof(int) * ts.size);
  g = (varr_t *) malloc(sizeof(varr_t) * v);
  for (i = 0; i < v; ++i) {
    vt[i] = ig[i] = 0;
    g[i].size = DEFAULT_VARR_SIZE;
    g[i].i = 0;
    g[i].arr = (int *) malloc(sizeof(int) * g[i].size);
  }
  for (i = 0; i < e; ++i) {
    scanf("%d %d", &k, &l);
    if (g[k].i == g[k].size) {
      g[k].size *= 2;
      g[k].arr = (int *) realloc(g[k].arr, sizeof(int) * g[k].size);
    }
    g[k].arr[g[k].i++] = l;
    ig[l]++;
  }
  topological_sort(v, vt, ig, &ts, g);
  for (i = 0; i < ts.i; ++i) printf("%d\n", ts.arr[i]);
  free(vt); free(ig); free(ts.arr);
  for (i = 0; i < v; ++i) free(g[i].arr);
}
```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.type	new_queue, @function
new_queue:
.LFB6:
	.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	$24, %edi
	call	malloc@PLT
	movq	%rax, -8(%rbp)
	movq	-8(%rbp), %rax
	movl	$0, 8(%rax)
	movq	-8(%rbp), %rax
	movl	8(%rax), %edx
	movq	-8(%rbp), %rax
	movl	%edx, 4(%rax)
	movq	-8(%rbp), %rax
	movl	4(%rax), %edx
	movq	-8(%rbp), %rax
	movl	%edx, (%rax)
	movq	-8(%rbp), %rax
	movl	-20(%rbp), %edx
	movl	%edx, 12(%rax)
	movl	-20(%rbp), %eax
	cltq
	salq	$2, %rax
	movq	%rax, %rdi
	call	malloc@PLT
	movq	%rax, %rdx
	movq	-8(%rbp), %rax
	movq	%rdx, 16(%rax)
	movl	$0, -12(%rbp)
	jmp	.L2
.L3:
	movq	-8(%rbp), %rax
	movq	16(%rax), %rdx
	movl	-12(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rdx, %rax
	movl	$-1, (%rax)
	addl	$1, -12(%rbp)
.L2:
	movl	-12(%rbp), %eax
	cmpl	-20(%rbp), %eax
	jl	.L3
	movq	-8(%rbp), %rax
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	new_queue, .-new_queue
	.type	free_queue, @function
free_queue:
.LFB7:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$16, %rsp
	movq	%rdi, -8(%rbp)
	movq	-8(%rbp), %rax
	movq	16(%rax), %rax
	movq	%rax, %rdi
	call	free@PLT
	movq	-8(%rbp), %rax
	movq	%rax, %rdi
	call	free@PLT
	nop
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.size	free_queue, .-free_queue
	.type	enqueue, @function
enqueue:
.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, -8(%rbp)
	movl	%esi, -12(%rbp)
	movq	-8(%rbp), %rax
	movl	8(%rax), %edx
	movq	-8(%rbp), %rax
	movl	12(%rax), %eax
	cmpl	%eax, %edx
	je	.L9
	movq	-8(%rbp), %rax
	movq	16(%rax), %rdx
	movq	-8(%rbp), %rax
	movl	4(%rax), %eax
	cltq
	salq	$2, %rax
	addq	%rax, %rdx
	movl	-12(%rbp), %eax
	movl	%eax, (%rdx)
	movq	-8(%rbp), %rax
	movl	4(%rax), %eax
	leal	1(%rax), %edx
	movq	-8(%rbp), %rax
	movl	12(%rax), %ecx
	movl	%edx, %eax
	cltd
	idivl	%ecx
	movq	-8(%rbp), %rax
	movl	%edx, 4(%rax)
	movq	-8(%rbp), %rax
	movl	8(%rax), %eax
	leal	-1(%rax), %edx
	movq	-8(%rbp), %rax
	movl	%edx, 8(%rax)
	jmp	.L6
.L9:
	nop
.L6:
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE8:
	.size	enqueue, .-enqueue
	.type	dequeue, @function
dequeue:
.LFB9:
	.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	-24(%rbp), %rax
	movl	8(%rax), %eax
	testl	%eax, %eax
	jne	.L11
	movl	$-1, %eax
	jmp	.L12
.L11:
	movq	-24(%rbp), %rax
	movq	16(%rax), %rdx
	movq	-24(%rbp), %rax
	movl	(%rax), %eax
	cltq
	salq	$2, %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	movl	%eax, -4(%rbp)
	movq	-24(%rbp), %rax
	movq	16(%rax), %rdx
	movq	-24(%rbp), %rax
	movl	(%rax), %eax
	cltq
	salq	$2, %rax
	addq	%rdx, %rax
	movl	$-1, (%rax)
	movq	-24(%rbp), %rax
	movl	(%rax), %eax
	leal	1(%rax), %edx
	movq	-24(%rbp), %rax
	movl	12(%rax), %ecx
	movl	%edx, %eax
	cltd
	idivl	%ecx
	movq	-24(%rbp), %rax
	movl	%edx, (%rax)
	movq	-24(%rbp), %rax
	movl	8(%rax), %eax
	leal	1(%rax), %edx
	movq	-24(%rbp), %rax
	movl	%edx, 8(%rax)
	movl	-4(%rbp), %eax
.L12:
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE9:
	.size	dequeue, .-dequeue
	.type	topological_sort, @function
topological_sort:
.LFB10:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$80, %rsp
	movl	%edi, -36(%rbp)
	movq	%rsi, -48(%rbp)
	movq	%rdx, -56(%rbp)
	movq	%rcx, -64(%rbp)
	movq	%r8, -72(%rbp)
	movl	$0, -24(%rbp)
	jmp	.L14
.L22:
	movl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-48(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	testl	%eax, %eax
	jne	.L15
	movl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-56(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	testl	%eax, %eax
	jne	.L15
	movl	-36(%rbp), %eax
	movl	%eax, %edi
	call	new_queue
	movq	%rax, -8(%rbp)
	movl	-24(%rbp), %edx
	movq	-8(%rbp), %rax
	movl	%edx, %esi
	movq	%rax, %rdi
	call	enqueue
	jmp	.L16
.L21:
	movq	-8(%rbp), %rax
	movq	%rax, %rdi
	call	dequeue
	movl	%eax, -16(%rbp)
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-48(%rbp), %rax
	addq	%rdx, %rax
	movl	$1, (%rax)
	movq	-64(%rbp), %rax
	movq	8(%rax), %rsi
	movq	-64(%rbp), %rax
	movl	4(%rax), %eax
	leal	1(%rax), %ecx
	movq	-64(%rbp), %rdx
	movl	%ecx, 4(%rdx)
	cltq
	salq	$2, %rax
	leaq	(%rsi,%rax), %rdx
	movl	-16(%rbp), %eax
	movl	%eax, (%rdx)
	movl	$0, -20(%rbp)
	jmp	.L17
.L20:
	movl	-16(%rbp), %eax
	cltq
	salq	$4, %rax
	movq	%rax, %rdx
	movq	-72(%rbp), %rax
	addq	%rdx, %rax
	movq	8(%rax), %rdx
	movl	-20(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	movl	%eax, -12(%rbp)
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-48(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	cmpl	$1, %eax
	je	.L23
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-56(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %edx
	subl	$1, %edx
	movl	%edx, (%rax)
	movl	(%rax), %eax
	testl	%eax, %eax
	jne	.L19
	movl	-12(%rbp), %edx
	movq	-8(%rbp), %rax
	movl	%edx, %esi
	movq	%rax, %rdi
	call	enqueue
	jmp	.L19
.L23:
	nop
.L19:
	addl	$1, -20(%rbp)
.L17:
	movl	-16(%rbp), %eax
	cltq
	salq	$4, %rax
	movq	%rax, %rdx
	movq	-72(%rbp), %rax
	addq	%rdx, %rax
	movl	4(%rax), %eax
	cmpl	%eax, -20(%rbp)
	jl	.L20
.L16:
	movq	-8(%rbp), %rax
	movl	8(%rax), %eax
	testl	%eax, %eax
	jne	.L21
	movq	-8(%rbp), %rax
	movq	%rax, %rdi
	call	free_queue
.L15:
	addl	$1, -24(%rbp)
.L14:
	movl	-24(%rbp), %eax
	cmpl	-36(%rbp), %eax
	jl	.L22
	nop
	nop
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE10:
	.size	topological_sort, .-topological_sort
	.section	.rodata
.LC0:
	.string	"%d %d"
.LC1:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB11:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	pushq	%rbx
	subq	$104, %rsp
	.cfi_offset 3, -24
	movl	%edi, -100(%rbp)
	movq	%rsi, -112(%rbp)
	movq	%fs:40, %rax
	movq	%rax, -24(%rbp)
	xorl	%eax, %eax
	leaq	-88(%rbp), %rdx
	leaq	-92(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-92(%rbp), %eax
	cltq
	salq	$2, %rax
	movq	%rax, %rdi
	call	malloc@PLT
	movq	%rax, -72(%rbp)
	movl	-92(%rbp), %eax
	cltq
	salq	$2, %rax
	movq	%rax, %rdi
	call	malloc@PLT
	movq	%rax, -64(%rbp)
	movl	-92(%rbp), %eax
	movl	%eax, -48(%rbp)
	movl	$0, -44(%rbp)
	movl	-48(%rbp), %eax
	cltq
	salq	$2, %rax
	movq	%rax, %rdi
	call	malloc@PLT
	movq	%rax, -40(%rbp)
	movl	-92(%rbp), %eax
	cltq
	salq	$4, %rax
	movq	%rax, %rdi
	call	malloc@PLT
	movq	%rax, -56(%rbp)
	movl	$0, -76(%rbp)
	jmp	.L25
.L26:
	movl	-76(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-64(%rbp), %rax
	addq	%rdx, %rax
	movl	$0, (%rax)
	movl	-76(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	movq	-72(%rbp), %rdx
	addq	%rcx, %rdx
	movl	(%rax), %eax
	movl	%eax, (%rdx)
	movl	-76(%rbp), %eax
	cltq
	salq	$4, %rax
	movq	%rax, %rdx
	movq	-56(%rbp), %rax
	addq	%rdx, %rax
	movl	$8, (%rax)
	movl	-76(%rbp), %eax
	cltq
	salq	$4, %rax
	movq	%rax, %rdx
	movq	-56(%rbp), %rax
	addq	%rdx, %rax
	movl	$0, 4(%rax)
	movl	-76(%rbp), %eax
	cltq
	salq	$4, %rax
	movq	%rax, %rdx
	movq	-56(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	cltq
	salq	$2, %rax
	movl	-76(%rbp), %edx
	movslq	%edx, %rdx
	movq	%rdx, %rcx
	salq	$4, %rcx
	movq	-56(%rbp), %rdx
	leaq	(%rcx,%rdx), %rbx
	movq	%rax, %rdi
	call	malloc@PLT
	movq	%rax, 8(%rbx)
	addl	$1, -76(%rbp)
.L25:
	movl	-92(%rbp), %eax
	cmpl	%eax, -76(%rbp)
	jl	.L26
	movl	$0, -76(%rbp)
	jmp	.L27
.L29:
	leaq	-80(%rbp), %rdx
	leaq	-84(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-84(%rbp), %eax
	cltq
	salq	$4, %rax
	movq	%rax, %rdx
	movq	-56(%rbp), %rax
	addq	%rdx, %rax
	movl	4(%rax), %edx
	movl	-84(%rbp), %eax
	cltq
	salq	$4, %rax
	movq	%rax, %rcx
	movq	-56(%rbp), %rax
	addq	%rcx, %rax
	movl	(%rax), %eax
	cmpl	%eax, %edx
	jne	.L28
	movl	-84(%rbp), %eax
	cltq
	salq	$4, %rax
	movq	%rax, %rdx
	movq	-56(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %edx
	movl	-84(%rbp), %eax
	cltq
	salq	$4, %rax
	movq	%rax, %rcx
	movq	-56(%rbp), %rax
	addq	%rcx, %rax
	addl	%edx, %edx
	movl	%edx, (%rax)
	movl	-84(%rbp), %eax
	cltq
	salq	$4, %rax
	movq	%rax, %rdx
	movq	-56(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movl	-84(%rbp), %eax
	cltq
	salq	$4, %rax
	movq	%rax, %rcx
	movq	-56(%rbp), %rax
	addq	%rcx, %rax
	movq	8(%rax), %rax
	movl	-84(%rbp), %ecx
	movslq	%ecx, %rcx
	movq	%rcx, %rsi
	salq	$4, %rsi
	movq	-56(%rbp), %rcx
	leaq	(%rsi,%rcx), %rbx
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	realloc@PLT
	movq	%rax, 8(%rbx)
.L28:
	movl	-84(%rbp), %eax
	cltq
	salq	$4, %rax
	movq	%rax, %rdx
	movq	-56(%rbp), %rax
	addq	%rdx, %rax
	movq	8(%rax), %rsi
	movl	-84(%rbp), %eax
	cltq
	salq	$4, %rax
	movq	%rax, %rdx
	movq	-56(%rbp), %rax
	addq	%rdx, %rax
	movl	4(%rax), %edx
	leal	1(%rdx), %ecx
	movl	%ecx, 4(%rax)
	movslq	%edx, %rax
	salq	$2, %rax
	leaq	(%rsi,%rax), %rdx
	movl	-80(%rbp), %eax
	movl	%eax, (%rdx)
	movl	-80(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-64(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %edx
	addl	$1, %edx
	movl	%edx, (%rax)
	addl	$1, -76(%rbp)
.L27:
	movl	-88(%rbp), %eax
	cmpl	%eax, -76(%rbp)
	jl	.L29
	movl	-92(%rbp), %eax
	movq	-56(%rbp), %rdi
	leaq	-48(%rbp), %rcx
	movq	-64(%rbp), %rdx
	movq	-72(%rbp), %rsi
	movq	%rdi, %r8
	movl	%eax, %edi
	call	topological_sort
	movl	$0, -76(%rbp)
	jmp	.L30
.L31:
	movq	-40(%rbp), %rdx
	movl	-76(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	addl	$1, -76(%rbp)
.L30:
	movl	-44(%rbp), %eax
	cmpl	%eax, -76(%rbp)
	jl	.L31
	movq	-72(%rbp), %rax
	movq	%rax, %rdi
	call	free@PLT
	movq	-64(%rbp), %rax
	movq	%rax, %rdi
	call	free@PLT
	movq	-40(%rbp), %rax
	movq	%rax, %rdi
	call	free@PLT
	movl	$0, -76(%rbp)
	jmp	.L32
.L33:
	movl	-76(%rbp), %eax
	cltq
	salq	$4, %rax
	movq	%rax, %rdx
	movq	-56(%rbp), %rax
	addq	%rdx, %rax
	movq	8(%rax), %rax
	movq	%rax, %rdi
	call	free@PLT
	addl	$1, -76(%rbp)
.L32:
	movl	-92(%rbp), %eax
	cmpl	%eax, -76(%rbp)
	jl	.L33
	movl	$0, %eax
	movq	-24(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L35
	call	__stack_chk_fail@PLT
.L35:
	movq	-8(%rbp), %rbx
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE11:
	.size	main, .-main
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:
```

Only output the optimized assembly code. Do not include any other text. Do not write any comments in the assembly code. Wrap the assembly code in ```assembly``` tags.
train
	.file	"temp.c"
	.text
	.type	new_queue, @function
new_queue:
.LFB6:
	.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	$24, %edi
	call	malloc@PLT
	movq	%rax, -8(%rbp)
	movq	-8(%rbp), %rax
	movl	$0, 8(%rax)
	movq	-8(%rbp), %rax
	movl	8(%rax), %edx
	movq	-8(%rbp), %rax
	movl	%edx, 4(%rax)
	movq	-8(%rbp), %rax
	movl	4(%rax), %edx
	movq	-8(%rbp), %rax
	movl	%edx, (%rax)
	movq	-8(%rbp), %rax
	movl	-20(%rbp), %edx
	movl	%edx, 12(%rax)
	movl	-20(%rbp), %eax
	cltq
	salq	$2, %rax
	movq	%rax, %rdi
	call	malloc@PLT
	movq	%rax, %rdx
	movq	-8(%rbp), %rax
	movq	%rdx, 16(%rax)
	movl	$0, -12(%rbp)
	jmp	.L2
.L3:
	movq	-8(%rbp), %rax
	movq	16(%rax), %rdx
	movl	-12(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rdx, %rax
	movl	$-1, (%rax)
	addl	$1, -12(%rbp)
.L2:
	movl	-12(%rbp), %eax
	cmpl	-20(%rbp), %eax
	jl	.L3
	movq	-8(%rbp), %rax
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	new_queue, .-new_queue
	.type	free_queue, @function
free_queue:
.LFB7:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$16, %rsp
	movq	%rdi, -8(%rbp)
	movq	-8(%rbp), %rax
	movq	16(%rax), %rax
	movq	%rax, %rdi
	call	free@PLT
	movq	-8(%rbp), %rax
	movq	%rax, %rdi
	call	free@PLT
	nop
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.size	free_queue, .-free_queue
	.type	enqueue, @function
enqueue:
.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, -8(%rbp)
	movl	%esi, -12(%rbp)
	movq	-8(%rbp), %rax
	movl	8(%rax), %edx
	movq	-8(%rbp), %rax
	movl	12(%rax), %eax
	cmpl	%eax, %edx
	je	.L9
	movq	-8(%rbp), %rax
	movq	16(%rax), %rdx
	movq	-8(%rbp), %rax
	movl	4(%rax), %eax
	cltq
	salq	$2, %rax
	addq	%rax, %rdx
	movl	-12(%rbp), %eax
	movl	%eax, (%rdx)
	movq	-8(%rbp), %rax
	movl	4(%rax), %eax
	leal	1(%rax), %edx
	movq	-8(%rbp), %rax
	movl	12(%rax), %ecx
	movl	%edx, %eax
	cltd
	idivl	%ecx
	movq	-8(%rbp), %rax
	movl	%edx, 4(%rax)
	movq	-8(%rbp), %rax
	movl	8(%rax), %eax
	leal	-1(%rax), %edx
	movq	-8(%rbp), %rax
	movl	%edx, 8(%rax)
	jmp	.L6
.L9:
	nop
.L6:
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE8:
	.size	enqueue, .-enqueue
	.type	dequeue, @function
dequeue:
.LFB9:
	.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	-24(%rbp), %rax
	movl	8(%rax), %eax
	testl	%eax, %eax
	jne	.L11
	movl	$-1, %eax
	jmp	.L12
.L11:
	movq	-24(%rbp), %rax
	movq	16(%rax), %rdx
	movq	-24(%rbp), %rax
	movl	(%rax), %eax
	cltq
	salq	$2, %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	movl	%eax, -4(%rbp)
	movq	-24(%rbp), %rax
	movq	16(%rax), %rdx
	movq	-24(%rbp), %rax
	movl	(%rax), %eax
	cltq
	salq	$2, %rax
	addq	%rdx, %rax
	movl	$-1, (%rax)
	movq	-24(%rbp), %rax
	movl	(%rax), %eax
	leal	1(%rax), %edx
	movq	-24(%rbp), %rax
	movl	12(%rax), %ecx
	movl	%edx, %eax
	cltd
	idivl	%ecx
	movq	-24(%rbp), %rax
	movl	%edx, (%rax)
	movq	-24(%rbp), %rax
	movl	8(%rax), %eax
	leal	1(%rax), %edx
	movq	-24(%rbp), %rax
	movl	%edx, 8(%rax)
	movl	-4(%rbp), %eax
.L12:
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE9:
	.size	dequeue, .-dequeue
	.type	topological_sort, @function
topological_sort:
.LFB10:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$80, %rsp
	movl	%edi, -36(%rbp)
	movq	%rsi, -48(%rbp)
	movq	%rdx, -56(%rbp)
	movq	%rcx, -64(%rbp)
	movq	%r8, -72(%rbp)
	movl	$0, -24(%rbp)
	jmp	.L14
.L22:
	movl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-48(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	testl	%eax, %eax
	jne	.L15
	movl	-24(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-56(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	testl	%eax, %eax
	jne	.L15
	movl	-36(%rbp), %eax
	movl	%eax, %edi
	call	new_queue
	movq	%rax, -8(%rbp)
	movl	-24(%rbp), %edx
	movq	-8(%rbp), %rax
	movl	%edx, %esi
	movq	%rax, %rdi
	call	enqueue
	jmp	.L16
.L21:
	movq	-8(%rbp), %rax
	movq	%rax, %rdi
	call	dequeue
	movl	%eax, -16(%rbp)
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-48(%rbp), %rax
	addq	%rdx, %rax
	movl	$1, (%rax)
	movq	-64(%rbp), %rax
	movq	8(%rax), %rsi
	movq	-64(%rbp), %rax
	movl	4(%rax), %eax
	leal	1(%rax), %ecx
	movq	-64(%rbp), %rdx
	movl	%ecx, 4(%rdx)
	cltq
	salq	$2, %rax
	leaq	(%rsi,%rax), %rdx
	movl	-16(%rbp), %eax
	movl	%eax, (%rdx)
	movl	$0, -20(%rbp)
	jmp	.L17
.L20:
	movl	-16(%rbp), %eax
	cltq
	salq	$4, %rax
	movq	%rax, %rdx
	movq	-72(%rbp), %rax
	addq	%rdx, %rax
	movq	8(%rax), %rdx
	movl	-20(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	movl	%eax, -12(%rbp)
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-48(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	cmpl	$1, %eax
	je	.L23
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-56(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %edx
	subl	$1, %edx
	movl	%edx, (%rax)
	movl	(%rax), %eax
	testl	%eax, %eax
	jne	.L19
	movl	-12(%rbp), %edx
	movq	-8(%rbp), %rax
	movl	%edx, %esi
	movq	%rax, %rdi
	call	enqueue
	jmp	.L19
.L23:
	nop
.L19:
	addl	$1, -20(%rbp)
.L17:
	movl	-16(%rbp), %eax
	cltq
	salq	$4, %rax
	movq	%rax, %rdx
	movq	-72(%rbp), %rax
	addq	%rdx, %rax
	movl	4(%rax), %eax
	cmpl	%eax, -20(%rbp)
	jl	.L20
.L16:
	movq	-8(%rbp), %rax
	movl	8(%rax), %eax
	testl	%eax, %eax
	jne	.L21
	movq	-8(%rbp), %rax
	movq	%rax, %rdi
	call	free_queue
.L15:
	addl	$1, -24(%rbp)
.L14:
	movl	-24(%rbp), %eax
	cmpl	-36(%rbp), %eax
	jl	.L22
	nop
	nop
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE10:
	.size	topological_sort, .-topological_sort
	.section	.rodata
.LC0:
	.string	"%d %d"
.LC1:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB11:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	pushq	%rbx
	subq	$104, %rsp
	.cfi_offset 3, -24
	movl	%edi, -100(%rbp)
	movq	%rsi, -112(%rbp)
	movq	%fs:40, %rax
	movq	%rax, -24(%rbp)
	xorl	%eax, %eax
	leaq	-88(%rbp), %rdx
	leaq	-92(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-92(%rbp), %eax
	cltq
	salq	$2, %rax
	movq	%rax, %rdi
	call	malloc@PLT
	movq	%rax, -72(%rbp)
	movl	-92(%rbp), %eax
	cltq
	salq	$2, %rax
	movq	%rax, %rdi
	call	malloc@PLT
	movq	%rax, -64(%rbp)
	movl	-92(%rbp), %eax
	movl	%eax, -48(%rbp)
	movl	$0, -44(%rbp)
	movl	-48(%rbp), %eax
	cltq
	salq	$2, %rax
	movq	%rax, %rdi
	call	malloc@PLT
	movq	%rax, -40(%rbp)
	movl	-92(%rbp), %eax
	cltq
	salq	$4, %rax
	movq	%rax, %rdi
	call	malloc@PLT
	movq	%rax, -56(%rbp)
	movl	$0, -76(%rbp)
	jmp	.L25
.L26:
	movl	-76(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-64(%rbp), %rax
	addq	%rdx, %rax
	movl	$0, (%rax)
	movl	-76(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	movq	-72(%rbp), %rdx
	addq	%rcx, %rdx
	movl	(%rax), %eax
	movl	%eax, (%rdx)
	movl	-76(%rbp), %eax
	cltq
	salq	$4, %rax
	movq	%rax, %rdx
	movq	-56(%rbp), %rax
	addq	%rdx, %rax
	movl	$8, (%rax)
	movl	-76(%rbp), %eax
	cltq
	salq	$4, %rax
	movq	%rax, %rdx
	movq	-56(%rbp), %rax
	addq	%rdx, %rax
	movl	$0, 4(%rax)
	movl	-76(%rbp), %eax
	cltq
	salq	$4, %rax
	movq	%rax, %rdx
	movq	-56(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	cltq
	salq	$2, %rax
	movl	-76(%rbp), %edx
	movslq	%edx, %rdx
	movq	%rdx, %rcx
	salq	$4, %rcx
	movq	-56(%rbp), %rdx
	leaq	(%rcx,%rdx), %rbx
	movq	%rax, %rdi
	call	malloc@PLT
	movq	%rax, 8(%rbx)
	addl	$1, -76(%rbp)
.L25:
	movl	-92(%rbp), %eax
	cmpl	%eax, -76(%rbp)
	jl	.L26
	movl	$0, -76(%rbp)
	jmp	.L27
.L29:
	leaq	-80(%rbp), %rdx
	leaq	-84(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-84(%rbp), %eax
	cltq
	salq	$4, %rax
	movq	%rax, %rdx
	movq	-56(%rbp), %rax
	addq	%rdx, %rax
	movl	4(%rax), %edx
	movl	-84(%rbp), %eax
	cltq
	salq	$4, %rax
	movq	%rax, %rcx
	movq	-56(%rbp), %rax
	addq	%rcx, %rax
	movl	(%rax), %eax
	cmpl	%eax, %edx
	jne	.L28
	movl	-84(%rbp), %eax
	cltq
	salq	$4, %rax
	movq	%rax, %rdx
	movq	-56(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %edx
	movl	-84(%rbp), %eax
	cltq
	salq	$4, %rax
	movq	%rax, %rcx
	movq	-56(%rbp), %rax
	addq	%rcx, %rax
	addl	%edx, %edx
	movl	%edx, (%rax)
	movl	-84(%rbp), %eax
	cltq
	salq	$4, %rax
	movq	%rax, %rdx
	movq	-56(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movl	-84(%rbp), %eax
	cltq
	salq	$4, %rax
	movq	%rax, %rcx
	movq	-56(%rbp), %rax
	addq	%rcx, %rax
	movq	8(%rax), %rax
	movl	-84(%rbp), %ecx
	movslq	%ecx, %rcx
	movq	%rcx, %rsi
	salq	$4, %rsi
	movq	-56(%rbp), %rcx
	leaq	(%rsi,%rcx), %rbx
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	realloc@PLT
	movq	%rax, 8(%rbx)
.L28:
	movl	-84(%rbp), %eax
	cltq
	salq	$4, %rax
	movq	%rax, %rdx
	movq	-56(%rbp), %rax
	addq	%rdx, %rax
	movq	8(%rax), %rsi
	movl	-84(%rbp), %eax
	cltq
	salq	$4, %rax
	movq	%rax, %rdx
	movq	-56(%rbp), %rax
	addq	%rdx, %rax
	movl	4(%rax), %edx
	leal	1(%rdx), %ecx
	movl	%ecx, 4(%rax)
	movslq	%edx, %rax
	salq	$2, %rax
	leaq	(%rsi,%rax), %rdx
	movl	-80(%rbp), %eax
	movl	%eax, (%rdx)
	movl	-80(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-64(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %edx
	addl	$1, %edx
	movl	%edx, (%rax)
	addl	$1, -76(%rbp)
.L27:
	movl	-88(%rbp), %eax
	cmpl	%eax, -76(%rbp)
	jl	.L29
	movl	-92(%rbp), %eax
	movq	-56(%rbp), %rdi
	leaq	-48(%rbp), %rcx
	movq	-64(%rbp), %rdx
	movq	-72(%rbp), %rsi
	movq	%rdi, %r8
	movl	%eax, %edi
	call	topological_sort
	movl	$0, -76(%rbp)
	jmp	.L30
.L31:
	movq	-40(%rbp), %rdx
	movl	-76(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	addl	$1, -76(%rbp)
.L30:
	movl	-44(%rbp), %eax
	cmpl	%eax, -76(%rbp)
	jl	.L31
	movq	-72(%rbp), %rax
	movq	%rax, %rdi
	call	free@PLT
	movq	-64(%rbp), %rax
	movq	%rax, %rdi
	call	free@PLT
	movq	-40(%rbp), %rax
	movq	%rax, %rdi
	call	free@PLT
	movl	$0, -76(%rbp)
	jmp	.L32
.L33:
	movl	-76(%rbp), %eax
	cltq
	salq	$4, %rax
	movq	%rax, %rdx
	movq	-56(%rbp), %rax
	addq	%rdx, %rax
	movq	8(%rax), %rax
	movq	%rax, %rdi
	call	free@PLT
	addl	$1, -76(%rbp)
.L32:
	movl	-92(%rbp), %eax
	cmpl	%eax, -76(%rbp)
	jl	.L33
	movl	$0, %eax
	movq	-24(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L35
	call	__stack_chk_fail@PLT
.L35:
	movq	-8(%rbp), %rbx
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE11:
	.size	main, .-main
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:
