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>

int work[400000][3];

int cmp(const void *a, const void *b) {
	const int *ai = a, *bi = b;
	return ai[0] - bi[0];
}

struct node {
	int n;
	struct node *l, *r;
};

void twalk(const struct node *root) {
	if (root == NULL) return;
	printf("walk: %d\n", root->n);
	twalk(root->l);
	twalk(root->r);
}

void tpush(struct node **root, int n) {
	//printf("push %d\n", n);
	while (*root)
		if ((*root)->n >= n) root = &(*root)->l;
		else root = &(*root)->r;

	*root = malloc(sizeof **root);
	(*root)->n = n;
	(*root)->l = NULL;
	(*root)->r = NULL;
}

void tpop(struct node **root, int n) {
	//printf("pop %d\n", n);
	while ((*root)->n != n)
		if ((*root)->n > n) root = &(*root)->l;
		else if ((*root)->n < n) root = &(*root)->r;

	struct node *c = NULL;
	if ((*root)->l == NULL) c = (*root)->r;
	else if ((*root)->r == NULL) c = (*root)->l;
	else {
		struct node **cp = &(*root)->r;
		while ((*cp)->l) cp = &(*cp)->l;
		(*root)->n = (*cp)->n;
		struct node *rem = *cp;
		if ((*cp)->l) *cp = (*cp)->l;
		else *cp = (*cp)->r;
		free(rem);
		return;
	}

	free(*root);
	*root = c;
}

int tmin(const struct node *root) {
	if (root == NULL) return -1;
	while (root->l) root = root->l;
	return root->n;
}

int main(void) {
	int n, q;
	scanf("%d%d", &n, &q);

	for (int i = 0; i < n; i++) {
		int s, t, x;
		scanf("%d%d%d", &s, &t, &x);
		work[i*2][0] = s-x;
		work[i*2][1] = 1;
		work[i*2][2] = x;
		work[i*2+1][0] = t-x;
		work[i*2+1][1] = 0;
		work[i*2+1][2] = x;
	}
	qsort(work, 2*n, sizeof work[0], cmp);

	struct node *root = NULL;
	int ind = 0;
	for (int i = 0; i < q; i++) {
		int d;
		scanf("%d", &d);
		while (ind < 2*n && work[ind][0] <= d) {
			//printf("work[%d]: %d %d %d\n", ind, work[ind][0], work[ind][1], work[ind][2]);
			if (work[ind][1]) tpush(&root, work[ind][2]);
			else tpop(&root, work[ind][2]);
			//twalk(root);
			ind++;
		}
		printf("%d\n", tmin(root));
	}
}
```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	work
	.bss
	.align 32
	.type	work, @object
	.size	work, 4800000
work:
	.zero	4800000
	.text
	.globl	cmp
	.type	cmp, @function
cmp:
.LFB6:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movq	%rdi, -24(%rbp)
	movq	%rsi, -32(%rbp)
	movq	-24(%rbp), %rax
	movq	%rax, -16(%rbp)
	movq	-32(%rbp), %rax
	movq	%rax, -8(%rbp)
	movq	-16(%rbp), %rax
	movl	(%rax), %edx
	movq	-8(%rbp), %rax
	movl	(%rax), %ecx
	movl	%edx, %eax
	subl	%ecx, %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	cmp, .-cmp
	.section	.rodata
.LC0:
	.string	"walk: %d\n"
	.text
	.globl	twalk
	.type	twalk, @function
twalk:
.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)
	cmpq	$0, -8(%rbp)
	je	.L6
	movq	-8(%rbp), %rax
	movl	(%rax), %eax
	movl	%eax, %esi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movq	-8(%rbp), %rax
	movq	8(%rax), %rax
	movq	%rax, %rdi
	call	twalk
	movq	-8(%rbp), %rax
	movq	16(%rax), %rax
	movq	%rax, %rdi
	call	twalk
	jmp	.L3
.L6:
	nop
.L3:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.size	twalk, .-twalk
	.globl	tpush
	.type	tpush, @function
tpush:
.LFB8:
	.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)
	movl	%esi, -12(%rbp)
	jmp	.L8
.L10:
	movq	-8(%rbp), %rax
	movq	(%rax), %rax
	movl	(%rax), %eax
	cmpl	%eax, -12(%rbp)
	jg	.L9
	movq	-8(%rbp), %rax
	movq	(%rax), %rax
	addq	$8, %rax
	movq	%rax, -8(%rbp)
	jmp	.L8
.L9:
	movq	-8(%rbp), %rax
	movq	(%rax), %rax
	addq	$16, %rax
	movq	%rax, -8(%rbp)
.L8:
	movq	-8(%rbp), %rax
	movq	(%rax), %rax
	testq	%rax, %rax
	jne	.L10
	movl	$24, %edi
	call	malloc@PLT
	movq	%rax, %rdx
	movq	-8(%rbp), %rax
	movq	%rdx, (%rax)
	movq	-8(%rbp), %rax
	movq	(%rax), %rax
	movl	-12(%rbp), %edx
	movl	%edx, (%rax)
	movq	-8(%rbp), %rax
	movq	(%rax), %rax
	movq	$0, 8(%rax)
	movq	-8(%rbp), %rax
	movq	(%rax), %rax
	movq	$0, 16(%rax)
	nop
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE8:
	.size	tpush, .-tpush
	.globl	tpop
	.type	tpop, @function
tpop:
.LFB9:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$48, %rsp
	movq	%rdi, -40(%rbp)
	movl	%esi, -44(%rbp)
	jmp	.L12
.L14:
	movq	-40(%rbp), %rax
	movq	(%rax), %rax
	movl	(%rax), %eax
	cmpl	%eax, -44(%rbp)
	jge	.L13
	movq	-40(%rbp), %rax
	movq	(%rax), %rax
	addq	$8, %rax
	movq	%rax, -40(%rbp)
	jmp	.L12
.L13:
	movq	-40(%rbp), %rax
	movq	(%rax), %rax
	movl	(%rax), %eax
	cmpl	%eax, -44(%rbp)
	jle	.L12
	movq	-40(%rbp), %rax
	movq	(%rax), %rax
	addq	$16, %rax
	movq	%rax, -40(%rbp)
.L12:
	movq	-40(%rbp), %rax
	movq	(%rax), %rax
	movl	(%rax), %eax
	cmpl	%eax, -44(%rbp)
	jne	.L14
	movq	$0, -24(%rbp)
	movq	-40(%rbp), %rax
	movq	(%rax), %rax
	movq	8(%rax), %rax
	testq	%rax, %rax
	jne	.L15
	movq	-40(%rbp), %rax
	movq	(%rax), %rax
	movq	16(%rax), %rax
	movq	%rax, -24(%rbp)
	jmp	.L16
.L15:
	movq	-40(%rbp), %rax
	movq	(%rax), %rax
	movq	16(%rax), %rax
	testq	%rax, %rax
	jne	.L17
	movq	-40(%rbp), %rax
	movq	(%rax), %rax
	movq	8(%rax), %rax
	movq	%rax, -24(%rbp)
	jmp	.L16
.L17:
	movq	-40(%rbp), %rax
	movq	(%rax), %rax
	addq	$16, %rax
	movq	%rax, -16(%rbp)
	jmp	.L18
.L19:
	movq	-16(%rbp), %rax
	movq	(%rax), %rax
	addq	$8, %rax
	movq	%rax, -16(%rbp)
.L18:
	movq	-16(%rbp), %rax
	movq	(%rax), %rax
	movq	8(%rax), %rax
	testq	%rax, %rax
	jne	.L19
	movq	-16(%rbp), %rax
	movq	(%rax), %rdx
	movq	-40(%rbp), %rax
	movq	(%rax), %rax
	movl	(%rdx), %edx
	movl	%edx, (%rax)
	movq	-16(%rbp), %rax
	movq	(%rax), %rax
	movq	%rax, -8(%rbp)
	movq	-16(%rbp), %rax
	movq	(%rax), %rax
	movq	8(%rax), %rax
	testq	%rax, %rax
	je	.L20
	movq	-16(%rbp), %rax
	movq	(%rax), %rax
	movq	8(%rax), %rdx
	movq	-16(%rbp), %rax
	movq	%rdx, (%rax)
	jmp	.L21
.L20:
	movq	-16(%rbp), %rax
	movq	(%rax), %rax
	movq	16(%rax), %rdx
	movq	-16(%rbp), %rax
	movq	%rdx, (%rax)
.L21:
	movq	-8(%rbp), %rax
	movq	%rax, %rdi
	call	free@PLT
	jmp	.L11
.L16:
	movq	-40(%rbp), %rax
	movq	(%rax), %rax
	movq	%rax, %rdi
	call	free@PLT
	movq	-40(%rbp), %rax
	movq	-24(%rbp), %rdx
	movq	%rdx, (%rax)
.L11:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE9:
	.size	tpop, .-tpop
	.globl	tmin
	.type	tmin, @function
tmin:
.LFB10:
	.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)
	cmpq	$0, -8(%rbp)
	jne	.L26
	movl	$-1, %eax
	jmp	.L25
.L27:
	movq	-8(%rbp), %rax
	movq	8(%rax), %rax
	movq	%rax, -8(%rbp)
.L26:
	movq	-8(%rbp), %rax
	movq	8(%rax), %rax
	testq	%rax, %rax
	jne	.L27
	movq	-8(%rbp), %rax
	movl	(%rax), %eax
.L25:
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE10:
	.size	tmin, .-tmin
	.section	.rodata
.LC1:
	.string	"%d%d"
.LC2:
	.string	"%d%d%d"
.LC3:
	.string	"%d"
.LC4:
	.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
	subq	$48, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-40(%rbp), %rdx
	leaq	-44(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -28(%rbp)
	jmp	.L29
.L30:
	leaq	-16(%rbp), %rcx
	leaq	-32(%rbp), %rdx
	leaq	-36(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-36(%rbp), %eax
	movl	-16(%rbp), %esi
	movl	-28(%rbp), %edx
	addl	%edx, %edx
	subl	%esi, %eax
	movl	%eax, %ecx
	movslq	%edx, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	movq	%rax, %rdx
	leaq	work(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	movl	-28(%rbp), %eax
	addl	%eax, %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	movq	%rax, %rdx
	leaq	4+work(%rip), %rax
	movl	$1, (%rdx,%rax)
	movl	-28(%rbp), %eax
	addl	%eax, %eax
	movl	-16(%rbp), %edx
	movslq	%eax, %rcx
	movq	%rcx, %rax
	addq	%rax, %rax
	addq	%rcx, %rax
	salq	$2, %rax
	movq	%rax, %rcx
	leaq	8+work(%rip), %rax
	movl	%edx, (%rcx,%rax)
	movl	-32(%rbp), %eax
	movl	-16(%rbp), %esi
	movl	-28(%rbp), %edx
	addl	%edx, %edx
	addl	$1, %edx
	subl	%esi, %eax
	movl	%eax, %ecx
	movslq	%edx, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	movq	%rax, %rdx
	leaq	work(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	movl	-28(%rbp), %eax
	addl	%eax, %eax
	addl	$1, %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	movq	%rax, %rdx
	leaq	4+work(%rip), %rax
	movl	$0, (%rdx,%rax)
	movl	-28(%rbp), %eax
	addl	%eax, %eax
	addl	$1, %eax
	movl	-16(%rbp), %edx
	movslq	%eax, %rcx
	movq	%rcx, %rax
	addq	%rax, %rax
	addq	%rcx, %rax
	salq	$2, %rax
	movq	%rax, %rcx
	leaq	8+work(%rip), %rax
	movl	%edx, (%rcx,%rax)
	addl	$1, -28(%rbp)
.L29:
	movl	-44(%rbp), %eax
	cmpl	%eax, -28(%rbp)
	jl	.L30
	movl	-44(%rbp), %eax
	addl	%eax, %eax
	cltq
	leaq	cmp(%rip), %rdx
	movq	%rdx, %rcx
	movl	$12, %edx
	movq	%rax, %rsi
	leaq	work(%rip), %rax
	movq	%rax, %rdi
	call	qsort@PLT
	movq	$0, -16(%rbp)
	movl	$0, -24(%rbp)
	movl	$0, -20(%rbp)
	jmp	.L31
.L37:
	leaq	-32(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	jmp	.L32
.L36:
	movl	-24(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	movq	%rax, %rdx
	leaq	4+work(%rip), %rax
	movl	(%rdx,%rax), %eax
	testl	%eax, %eax
	je	.L33
	movl	-24(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	movq	%rax, %rdx
	leaq	8+work(%rip), %rax
	movl	(%rdx,%rax), %edx
	leaq	-16(%rbp), %rax
	movl	%edx, %esi
	movq	%rax, %rdi
	call	tpush
	jmp	.L34
.L33:
	movl	-24(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	movq	%rax, %rdx
	leaq	8+work(%rip), %rax
	movl	(%rdx,%rax), %edx
	leaq	-16(%rbp), %rax
	movl	%edx, %esi
	movq	%rax, %rdi
	call	tpop
.L34:
	addl	$1, -24(%rbp)
.L32:
	movl	-44(%rbp), %eax
	addl	%eax, %eax
	cmpl	%eax, -24(%rbp)
	jge	.L35
	movl	-24(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	movq	%rax, %rdx
	leaq	work(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-32(%rbp), %eax
	cmpl	%eax, %edx
	jle	.L36
.L35:
	movq	-16(%rbp), %rax
	movq	%rax, %rdi
	call	tmin
	movl	%eax, %esi
	leaq	.LC4(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	addl	$1, -20(%rbp)
.L31:
	movl	-40(%rbp), %eax
	cmpl	%eax, -20(%rbp)
	jl	.L37
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L39
	call	__stack_chk_fail@PLT
.L39:
	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
	.p2align 4
	.globl	cmp
	.type	cmp, @function
cmp:
.LFB39:
	.cfi_startproc
	endbr64
	movl	(%rdi), %eax
	subl	(%rsi), %eax
	ret
	.cfi_endproc
.LFE39:
	.size	cmp, .-cmp
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"walk: %d\n"
	.text
	.p2align 4
	.globl	twalk
	.type	twalk, @function
twalk:
.LFB40:
	.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
	subq	$40, %rsp
	.cfi_def_cfa_offset 96
	movq	%rdi, 16(%rsp)
	testq	%rdi, %rdi
	je	.L3
	leaq	.LC0(%rip), %rbp
.L4:
	movq	16(%rsp), %rbx
	movq	%rbp, %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	movl	(%rbx), %edx
	call	__printf_chk@PLT
	movq	8(%rbx), %rax
	movq	%rax, (%rsp)
	testq	%rax, %rax
	je	.L5
.L20:
	movq	(%rsp), %rbx
	movq	%rbp, %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	movl	(%rbx), %edx
	call	__printf_chk@PLT
	movq	8(%rbx), %rax
	movq	%rax, 8(%rsp)
	testq	%rax, %rax
	je	.L6
.L19:
	movq	8(%rsp), %rbx
	movq	%rbp, %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	movl	(%rbx), %edx
	call	__printf_chk@PLT
	movq	8(%rbx), %r15
	testq	%r15, %r15
	je	.L7
.L18:
	movl	(%r15), %edx
	movq	%rbp, %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	8(%r15), %rbx
	testq	%rbx, %rbx
	je	.L8
.L17:
	movl	(%rbx), %edx
	movq	%rbp, %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	8(%rbx), %r13
	testq	%r13, %r13
	je	.L9
.L16:
	movl	0(%r13), %edx
	movq	%rbp, %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	8(%r13), %r12
	testq	%r12, %r12
	je	.L10
.L15:
	movl	(%r12), %edx
	movq	%rbp, %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	8(%r12), %r14
	testq	%r14, %r14
	je	.L11
.L14:
	movl	(%r14), %edx
	movq	%rbp, %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	8(%r14), %r9
	testq	%r9, %r9
	je	.L12
.L13:
	movl	(%r9), %edx
	movq	%rbp, %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	movq	%r9, 24(%rsp)
	call	__printf_chk@PLT
	movq	24(%rsp), %r9
	movq	8(%r9), %rdi
	call	twalk
	movq	24(%rsp), %r9
	movq	16(%r9), %r9
	testq	%r9, %r9
	jne	.L13
.L12:
	movq	16(%r14), %r14
	testq	%r14, %r14
	jne	.L14
.L11:
	movq	16(%r12), %r12
	testq	%r12, %r12
	jne	.L15
.L10:
	movq	16(%r13), %r13
	testq	%r13, %r13
	jne	.L16
.L9:
	movq	16(%rbx), %rbx
	testq	%rbx, %rbx
	jne	.L17
.L8:
	movq	16(%r15), %r15
	testq	%r15, %r15
	jne	.L18
.L7:
	movq	8(%rsp), %rax
	movq	16(%rax), %rax
	movq	%rax, 8(%rsp)
	testq	%rax, %rax
	jne	.L19
.L6:
	movq	(%rsp), %rax
	movq	16(%rax), %rax
	movq	%rax, (%rsp)
	testq	%rax, %rax
	jne	.L20
.L5:
	movq	16(%rsp), %rax
	movq	16(%rax), %rax
	movq	%rax, 16(%rsp)
	testq	%rax, %rax
	jne	.L4
.L3:
	addq	$40, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE40:
	.size	twalk, .-twalk
	.p2align 4
	.globl	tpush
	.type	tpush, @function
tpush:
.LFB41:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movl	%esi, %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 24
	.cfi_offset 3, -24
	subq	$8, %rsp
	.cfi_def_cfa_offset 32
	movq	(%rdi), %rax
	testq	%rax, %rax
	je	.L69
	.p2align 4,,10
	.p2align 3
.L64:
	leaq	8(%rax), %rdx
	leaq	16(%rax), %rbx
	cmpl	(%rax), %ebp
	cmovle	%rdx, %rbx
	movq	(%rbx), %rax
	testq	%rax, %rax
	jne	.L64
.L61:
	movl	$24, %edi
	call	malloc@PLT
	movq	%rax, (%rbx)
	movl	%ebp, (%rax)
	movq	$0, 8(%rax)
	movq	(%rbx), %rax
	movq	$0, 16(%rax)
	addq	$8, %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
.L69:
	.cfi_restore_state
	movq	%rdi, %rbx
	jmp	.L61
	.cfi_endproc
.LFE41:
	.size	tpush, .-tpush
	.p2align 4
	.globl	tpop
	.type	tpop, @function
tpop:
.LFB42:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	pushq	%rbx
	.cfi_def_cfa_offset 24
	.cfi_offset 3, -24
	movq	%rdi, %rbx
	subq	$8, %rsp
	.cfi_def_cfa_offset 32
	movq	(%rdi), %rdi
	movl	(%rdi), %eax
	.p2align 4,,10
	.p2align 3
.L87:
	cmpl	%eax, %esi
	je	.L72
.L88:
	cmpl	%eax, %esi
	jge	.L73
	leaq	8(%rdi), %rbx
	movq	8(%rdi), %rdi
	movl	(%rdi), %eax
	cmpl	%eax, %esi
	jne	.L88
.L72:
	movq	8(%rdi), %rbp
	movq	16(%rdi), %rdx
	testq	%rbp, %rbp
	je	.L80
	testq	%rdx, %rdx
	je	.L76
	movq	8(%rdx), %rax
	testq	%rax, %rax
	jne	.L78
	jmp	.L89
	.p2align 4,,10
	.p2align 3
.L81:
	movq	%r8, %rdx
.L78:
	movq	%rax, %r8
	movq	8(%rax), %rax
	testq	%rax, %rax
	jne	.L81
	leaq	8(%rdx), %rcx
.L79:
	movl	(%r8), %eax
	movl	%eax, (%rdi)
	movq	16(%r8), %rax
	movq	%r8, %rdi
	movq	%rax, (%rcx)
	addq	$8, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 24
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	jmp	free@PLT
	.p2align 4,,10
	.p2align 3
.L80:
	.cfi_restore_state
	movq	%rdx, %rbp
.L76:
	call	free@PLT
	movq	%rbp, (%rbx)
	addq	$8, %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
.L73:
	.cfi_restore_state
	jle	.L87
	leaq	16(%rdi), %rbx
	movq	16(%rdi), %rdi
	movl	(%rdi), %eax
	jmp	.L87
.L89:
	leaq	16(%rdi), %rcx
	movq	%rdx, %r8
	jmp	.L79
	.cfi_endproc
.LFE42:
	.size	tpop, .-tpop
	.p2align 4
	.globl	tmin
	.type	tmin, @function
tmin:
.LFB43:
	.cfi_startproc
	endbr64
	testq	%rdi, %rdi
	je	.L93
	.p2align 4,,10
	.p2align 3
.L92:
	movq	%rdi, %rax
	movq	8(%rdi), %rdi
	testq	%rdi, %rdi
	jne	.L92
	movl	(%rax), %eax
	ret
.L93:
	movl	$-1, %eax
	ret
	.cfi_endproc
.LFE43:
	.size	tmin, .-tmin
	.section	.rodata.str1.1
.LC1:
	.string	"%d%d"
.LC2:
	.string	"%d%d%d"
.LC3:
	.string	"%d"
.LC4:
	.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
	leaq	.LC1(%rip), %rdi
	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
	subq	$72, %rsp
	.cfi_def_cfa_offset 128
	movq	%fs:40, %rax
	movq	%rax, 56(%rsp)
	xorl	%eax, %eax
	leaq	36(%rsp), %rdx
	leaq	32(%rsp), %rsi
	call	__isoc99_scanf@PLT
	movl	32(%rsp), %eax
	testl	%eax, %eax
	jle	.L96
	leaq	44(%rsp), %rax
	leaq	work(%rip), %rbx
	xorl	%r13d, %r13d
	movq	%rax, 24(%rsp)
	leaq	48(%rsp), %r15
	leaq	40(%rsp), %r14
	leaq	.LC2(%rip), %rbp
	.p2align 4,,10
	.p2align 3
.L97:
	movq	24(%rsp), %rdx
	movq	%r15, %rcx
	movq	%r14, %rsi
	movq	%rbp, %rdi
	xorl	%eax, %eax
	addl	$1, %r13d
	addq	$24, %rbx
	call	__isoc99_scanf@PLT
	movl	48(%rsp), %eax
	movl	40(%rsp), %edx
	movl	$1, -20(%rbx)
	movl	$0, -8(%rbx)
	subl	%eax, %edx
	movl	%eax, -16(%rbx)
	movl	%edx, -24(%rbx)
	movl	44(%rsp), %edx
	movl	%eax, -4(%rbx)
	subl	%eax, %edx
	movl	32(%rsp), %eax
	movl	%edx, -12(%rbx)
	cmpl	%r13d, %eax
	jg	.L97
.L96:
	addl	%eax, %eax
	movl	$12, %edx
	leaq	cmp(%rip), %rcx
	movslq	%eax, %rsi
	leaq	work(%rip), %rdi
	call	qsort@PLT
	movl	36(%rsp), %edx
	movq	$0, 48(%rsp)
	testl	%edx, %edx
	jle	.L118
	leaq	44(%rsp), %rax
	movl	$0, 20(%rsp)
	xorl	%r14d, %r14d
	xorl	%r13d, %r13d
	movq	%rax, 24(%rsp)
	leaq	48(%rsp), %rax
	movq	%rax, 8(%rsp)
	.p2align 4,,10
	.p2align 3
.L98:
	movq	24(%rsp), %rsi
	leaq	.LC3(%rip), %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	32(%rsp), %ebp
	leal	(%rbp,%rbp), %eax
	cmpl	%r13d, %eax
	jle	.L99
	movslq	%r13d, %rax
	leaq	work(%rip), %rcx
	leaq	(%rax,%rax,2), %rax
	leaq	(%rcx,%rax,4), %r15
	.p2align 4,,10
	.p2align 3
.L100:
	movl	44(%rsp), %eax
	cmpl	%eax, (%r15)
	jg	.L99
	movl	4(%r15), %eax
	movl	8(%r15), %r12d
	testl	%eax, %eax
	je	.L101
	testq	%r14, %r14
	je	.L121
	.p2align 4,,10
	.p2align 3
.L105:
	leaq	8(%r14), %rax
	leaq	16(%r14), %rdx
	cmpl	%r12d, (%r14)
	cmovl	%rdx, %rax
	movq	(%rax), %r14
	movq	%rax, %rbx
	testq	%r14, %r14
	jne	.L105
.L102:
	movl	$24, %edi
	call	malloc@PLT
	movq	%rax, (%rbx)
	movl	%r12d, (%rax)
	movq	$0, 8(%rax)
	movq	(%rbx), %rax
	movq	$0, 16(%rax)
	movq	48(%rsp), %r14
.L106:
	addl	$1, %r13d
	leal	(%rbp,%rbp), %eax
	addq	$12, %r15
	cmpl	%r13d, %eax
	jg	.L100
.L99:
	testq	%r14, %r14
	je	.L125
	movq	%r14, %rax
	.p2align 4,,10
	.p2align 3
.L117:
	movq	%rax, %rdx
	movq	8(%rax), %rax
	testq	%rax, %rax
	jne	.L117
	movl	(%rdx), %edx
.L116:
	leaq	.LC4(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	addl	$1, 20(%rsp)
	movl	20(%rsp), %eax
	cmpl	%eax, 36(%rsp)
	jg	.L98
.L118:
	movq	56(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L138
	addq	$72, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 56
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L101:
	.cfi_restore_state
	movl	(%r14), %eax
	movq	8(%rsp), %rbp
	movq	%r14, %rdi
	.p2align 4,,10
	.p2align 3
.L137:
	cmpl	%r12d, %eax
	je	.L107
.L139:
	cmpl	%r12d, %eax
	jle	.L108
	leaq	8(%rdi), %rbp
	movq	8(%rdi), %rdi
	movl	(%rdi), %eax
	cmpl	%r12d, %eax
	jne	.L139
.L107:
	movq	8(%rdi), %r12
	movq	16(%rdi), %rsi
	testq	%r12, %r12
	je	.L123
	testq	%rsi, %rsi
	je	.L111
	movq	8(%rsi), %rax
	testq	%rax, %rax
	jne	.L113
	jmp	.L140
	.p2align 4,,10
	.p2align 3
.L124:
	movq	%r10, %rsi
.L113:
	movq	%rax, %r10
	movq	8(%rax), %rax
	testq	%rax, %rax
	jne	.L124
	leaq	8(%rsi), %rdx
.L114:
	movl	(%r10), %eax
	movl	%eax, (%rdi)
	movq	16(%r10), %rax
	movq	%r10, %rdi
	movq	%rax, (%rdx)
	call	free@PLT
	movl	32(%rsp), %ebp
	jmp	.L106
	.p2align 4,,10
	.p2align 3
.L108:
	jge	.L137
	leaq	16(%rdi), %rbp
	movq	16(%rdi), %rdi
	movl	(%rdi), %eax
	jmp	.L137
	.p2align 4,,10
	.p2align 3
.L123:
	movq	%rsi, %r12
.L111:
	call	free@PLT
	movq	%r12, 0(%rbp)
	movl	32(%rsp), %ebp
	movq	48(%rsp), %r14
	jmp	.L106
	.p2align 4,,10
	.p2align 3
.L121:
	movq	8(%rsp), %rbx
	jmp	.L102
.L140:
	leaq	16(%rdi), %rdx
	movq	%rsi, %r10
	jmp	.L114
.L125:
	orl	$-1, %edx
	jmp	.L116
.L138:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE44:
	.size	main, .-main
	.globl	work
	.bss
	.align 32
	.type	work, @object
	.size	work, 4800000
work:
	.zero	4800000
	.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	cmp
	.type	cmp, @function
cmp:
.LFB39:
	.cfi_startproc
	endbr64
	movl	(%rdi), %eax
	subl	(%rsi), %eax
	ret
	.cfi_endproc
.LFE39:
	.size	cmp, .-cmp
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"walk: %d\n"
	.text
	.p2align 4
	.globl	twalk
	.type	twalk, @function
twalk:
.LFB40:
	.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
	subq	$40, %rsp
	.cfi_def_cfa_offset 96
	movq	%rdi, 16(%rsp)
	testq	%rdi, %rdi
	je	.L3
	leaq	.LC0(%rip), %rbp
.L4:
	movq	16(%rsp), %rbx
	movq	%rbp, %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	movl	(%rbx), %edx
	call	__printf_chk@PLT
	movq	8(%rbx), %rax
	movq	%rax, (%rsp)
	testq	%rax, %rax
	je	.L5
.L20:
	movq	(%rsp), %rbx
	movq	%rbp, %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	movl	(%rbx), %edx
	call	__printf_chk@PLT
	movq	8(%rbx), %rax
	movq	%rax, 8(%rsp)
	testq	%rax, %rax
	je	.L6
.L19:
	movq	8(%rsp), %rbx
	movq	%rbp, %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	movl	(%rbx), %edx
	call	__printf_chk@PLT
	movq	8(%rbx), %r15
	testq	%r15, %r15
	je	.L7
.L18:
	movl	(%r15), %edx
	movq	%rbp, %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	8(%r15), %rbx
	testq	%rbx, %rbx
	je	.L8
.L17:
	movl	(%rbx), %edx
	movq	%rbp, %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	8(%rbx), %r13
	testq	%r13, %r13
	je	.L9
.L16:
	movl	0(%r13), %edx
	movq	%rbp, %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	8(%r13), %r12
	testq	%r12, %r12
	je	.L10
.L15:
	movl	(%r12), %edx
	movq	%rbp, %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	8(%r12), %r14
	testq	%r14, %r14
	je	.L11
.L14:
	movl	(%r14), %edx
	movq	%rbp, %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	8(%r14), %r9
	testq	%r9, %r9
	je	.L12
.L13:
	movl	(%r9), %edx
	movq	%rbp, %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	movq	%r9, 24(%rsp)
	call	__printf_chk@PLT
	movq	24(%rsp), %r9
	movq	8(%r9), %rdi
	call	twalk
	movq	24(%rsp), %r9
	movq	16(%r9), %r9
	testq	%r9, %r9
	jne	.L13
.L12:
	movq	16(%r14), %r14
	testq	%r14, %r14
	jne	.L14
.L11:
	movq	16(%r12), %r12
	testq	%r12, %r12
	jne	.L15
.L10:
	movq	16(%r13), %r13
	testq	%r13, %r13
	jne	.L16
.L9:
	movq	16(%rbx), %rbx
	testq	%rbx, %rbx
	jne	.L17
.L8:
	movq	16(%r15), %r15
	testq	%r15, %r15
	jne	.L18
.L7:
	movq	8(%rsp), %rax
	movq	16(%rax), %rax
	movq	%rax, 8(%rsp)
	testq	%rax, %rax
	jne	.L19
.L6:
	movq	(%rsp), %rax
	movq	16(%rax), %rax
	movq	%rax, (%rsp)
	testq	%rax, %rax
	jne	.L20
.L5:
	movq	16(%rsp), %rax
	movq	16(%rax), %rax
	movq	%rax, 16(%rsp)
	testq	%rax, %rax
	jne	.L4
.L3:
	addq	$40, %rsp
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE40:
	.size	twalk, .-twalk
	.p2align 4
	.globl	tpush
	.type	tpush, @function
tpush:
.LFB41:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movl	%esi, %ebp
	pushq	%rbx
	.cfi_def_cfa_offset 24
	.cfi_offset 3, -24
	subq	$8, %rsp
	.cfi_def_cfa_offset 32
	movq	(%rdi), %rax
	testq	%rax, %rax
	je	.L69
	.p2align 4,,10
	.p2align 3
.L64:
	leaq	8(%rax), %rdx
	leaq	16(%rax), %rbx
	cmpl	(%rax), %ebp
	cmovle	%rdx, %rbx
	movq	(%rbx), %rax
	testq	%rax, %rax
	jne	.L64
.L61:
	movl	$24, %edi
	call	malloc@PLT
	movq	%rax, (%rbx)
	movl	%ebp, (%rax)
	movq	$0, 8(%rax)
	movq	(%rbx), %rax
	movq	$0, 16(%rax)
	addq	$8, %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
.L69:
	.cfi_restore_state
	movq	%rdi, %rbx
	jmp	.L61
	.cfi_endproc
.LFE41:
	.size	tpush, .-tpush
	.p2align 4
	.globl	tpop
	.type	tpop, @function
tpop:
.LFB42:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	pushq	%rbx
	.cfi_def_cfa_offset 24
	.cfi_offset 3, -24
	movq	%rdi, %rbx
	subq	$8, %rsp
	.cfi_def_cfa_offset 32
	movq	(%rdi), %rdi
	movl	(%rdi), %eax
	.p2align 4,,10
	.p2align 3
.L87:
	cmpl	%eax, %esi
	je	.L72
.L88:
	cmpl	%eax, %esi
	jge	.L73
	leaq	8(%rdi), %rbx
	movq	8(%rdi), %rdi
	movl	(%rdi), %eax
	cmpl	%eax, %esi
	jne	.L88
.L72:
	movq	8(%rdi), %rbp
	movq	16(%rdi), %rdx
	testq	%rbp, %rbp
	je	.L80
	testq	%rdx, %rdx
	je	.L76
	movq	8(%rdx), %rax
	testq	%rax, %rax
	jne	.L78
	jmp	.L89
	.p2align 4,,10
	.p2align 3
.L81:
	movq	%r8, %rdx
.L78:
	movq	%rax, %r8
	movq	8(%rax), %rax
	testq	%rax, %rax
	jne	.L81
	leaq	8(%rdx), %rcx
.L79:
	movl	(%r8), %eax
	movl	%eax, (%rdi)
	movq	16(%r8), %rax
	movq	%r8, %rdi
	movq	%rax, (%rcx)
	addq	$8, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 24
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	jmp	free@PLT
	.p2align 4,,10
	.p2align 3
.L80:
	.cfi_restore_state
	movq	%rdx, %rbp
.L76:
	call	free@PLT
	movq	%rbp, (%rbx)
	addq	$8, %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
.L73:
	.cfi_restore_state
	jle	.L87
	leaq	16(%rdi), %rbx
	movq	16(%rdi), %rdi
	movl	(%rdi), %eax
	jmp	.L87
.L89:
	leaq	16(%rdi), %rcx
	movq	%rdx, %r8
	jmp	.L79
	.cfi_endproc
.LFE42:
	.size	tpop, .-tpop
	.p2align 4
	.globl	tmin
	.type	tmin, @function
tmin:
.LFB43:
	.cfi_startproc
	endbr64
	testq	%rdi, %rdi
	je	.L93
	.p2align 4,,10
	.p2align 3
.L92:
	movq	%rdi, %rax
	movq	8(%rdi), %rdi
	testq	%rdi, %rdi
	jne	.L92
	movl	(%rax), %eax
	ret
.L93:
	movl	$-1, %eax
	ret
	.cfi_endproc
.LFE43:
	.size	tmin, .-tmin
	.section	.rodata.str1.1
.LC1:
	.string	"%d%d"
.LC2:
	.string	"%d%d%d"
.LC3:
	.string	"%d"
.LC4:
	.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
	leaq	.LC1(%rip), %rdi
	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
	subq	$72, %rsp
	.cfi_def_cfa_offset 128
	movq	%fs:40, %rax
	movq	%rax, 56(%rsp)
	xorl	%eax, %eax
	leaq	36(%rsp), %rdx
	leaq	32(%rsp), %rsi
	call	__isoc99_scanf@PLT
	movl	32(%rsp), %eax
	testl	%eax, %eax
	jle	.L96
	leaq	44(%rsp), %rax
	leaq	work(%rip), %rbx
	xorl	%r13d, %r13d
	movq	%rax, 24(%rsp)
	leaq	48(%rsp), %r15
	leaq	40(%rsp), %r14
	leaq	.LC2(%rip), %rbp
	.p2align 4,,10
	.p2align 3
.L97:
	movq	24(%rsp), %rdx
	movq	%r15, %rcx
	movq	%r14, %rsi
	movq	%rbp, %rdi
	xorl	%eax, %eax
	addl	$1, %r13d
	addq	$24, %rbx
	call	__isoc99_scanf@PLT
	movl	48(%rsp), %eax
	movl	40(%rsp), %edx
	movl	$1, -20(%rbx)
	movl	$0, -8(%rbx)
	subl	%eax, %edx
	movl	%eax, -16(%rbx)
	movl	%edx, -24(%rbx)
	movl	44(%rsp), %edx
	movl	%eax, -4(%rbx)
	subl	%eax, %edx
	movl	32(%rsp), %eax
	movl	%edx, -12(%rbx)
	cmpl	%r13d, %eax
	jg	.L97
.L96:
	addl	%eax, %eax
	movl	$12, %edx
	leaq	cmp(%rip), %rcx
	movslq	%eax, %rsi
	leaq	work(%rip), %rdi
	call	qsort@PLT
	movl	36(%rsp), %edx
	movq	$0, 48(%rsp)
	testl	%edx, %edx
	jle	.L118
	leaq	44(%rsp), %rax
	movl	$0, 20(%rsp)
	xorl	%r14d, %r14d
	xorl	%r13d, %r13d
	movq	%rax, 24(%rsp)
	leaq	48(%rsp), %rax
	movq	%rax, 8(%rsp)
	.p2align 4,,10
	.p2align 3
.L98:
	movq	24(%rsp), %rsi
	leaq	.LC3(%rip), %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	32(%rsp), %ebp
	leal	(%rbp,%rbp), %eax
	cmpl	%r13d, %eax
	jle	.L99
	movslq	%r13d, %rax
	leaq	work(%rip), %rcx
	leaq	(%rax,%rax,2), %rax
	leaq	(%rcx,%rax,4), %r15
	.p2align 4,,10
	.p2align 3
.L100:
	movl	44(%rsp), %eax
	cmpl	%eax, (%r15)
	jg	.L99
	movl	4(%r15), %eax
	movl	8(%r15), %r12d
	testl	%eax, %eax
	je	.L101
	testq	%r14, %r14
	je	.L121
	.p2align 4,,10
	.p2align 3
.L105:
	leaq	8(%r14), %rax
	leaq	16(%r14), %rdx
	cmpl	%r12d, (%r14)
	cmovl	%rdx, %rax
	movq	(%rax), %r14
	movq	%rax, %rbx
	testq	%r14, %r14
	jne	.L105
.L102:
	movl	$24, %edi
	call	malloc@PLT
	movq	%rax, (%rbx)
	movl	%r12d, (%rax)
	movq	$0, 8(%rax)
	movq	(%rbx), %rax
	movq	$0, 16(%rax)
	movq	48(%rsp), %r14
.L106:
	addl	$1, %r13d
	leal	(%rbp,%rbp), %eax
	addq	$12, %r15
	cmpl	%r13d, %eax
	jg	.L100
.L99:
	testq	%r14, %r14
	je	.L125
	movq	%r14, %rax
	.p2align 4,,10
	.p2align 3
.L117:
	movq	%rax, %rdx
	movq	8(%rax), %rax
	testq	%rax, %rax
	jne	.L117
	movl	(%rdx), %edx
.L116:
	leaq	.LC4(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	addl	$1, 20(%rsp)
	movl	20(%rsp), %eax
	cmpl	%eax, 36(%rsp)
	jg	.L98
.L118:
	movq	56(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L138
	addq	$72, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 56
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L101:
	.cfi_restore_state
	movl	(%r14), %eax
	movq	8(%rsp), %rbp
	movq	%r14, %rdi
	.p2align 4,,10
	.p2align 3
.L137:
	cmpl	%r12d, %eax
	je	.L107
.L139:
	cmpl	%r12d, %eax
	jle	.L108
	leaq	8(%rdi), %rbp
	movq	8(%rdi), %rdi
	movl	(%rdi), %eax
	cmpl	%r12d, %eax
	jne	.L139
.L107:
	movq	8(%rdi), %r12
	movq	16(%rdi), %rsi
	testq	%r12, %r12
	je	.L123
	testq	%rsi, %rsi
	je	.L111
	movq	8(%rsi), %rax
	testq	%rax, %rax
	jne	.L113
	jmp	.L140
	.p2align 4,,10
	.p2align 3
.L124:
	movq	%r10, %rsi
.L113:
	movq	%rax, %r10
	movq	8(%rax), %rax
	testq	%rax, %rax
	jne	.L124
	leaq	8(%rsi), %rdx
.L114:
	movl	(%r10), %eax
	movl	%eax, (%rdi)
	movq	16(%r10), %rax
	movq	%r10, %rdi
	movq	%rax, (%rdx)
	call	free@PLT
	movl	32(%rsp), %ebp
	jmp	.L106
	.p2align 4,,10
	.p2align 3
.L108:
	jge	.L137
	leaq	16(%rdi), %rbp
	movq	16(%rdi), %rdi
	movl	(%rdi), %eax
	jmp	.L137
	.p2align 4,,10
	.p2align 3
.L123:
	movq	%rsi, %r12
.L111:
	call	free@PLT
	movq	%r12, 0(%rbp)
	movl	32(%rsp), %ebp
	movq	48(%rsp), %r14
	jmp	.L106
	.p2align 4,,10
	.p2align 3
.L121:
	movq	8(%rsp), %rbx
	jmp	.L102
.L140:
	leaq	16(%rdi), %rdx
	movq	%rsi, %r10
	jmp	.L114
.L125:
	orl	$-1, %edx
	jmp	.L116
.L138:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE44:
	.size	main, .-main
	.globl	work
	.bss
	.align 32
	.type	work, @object
	.size	work, 4800000
work:
	.zero	4800000
	.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>

int work[400000][3];

int cmp(const void *a, const void *b) {
	const int *ai = a, *bi = b;
	return ai[0] - bi[0];
}

struct node {
	int n;
	struct node *l, *r;
};

void twalk(const struct node *root) {
	if (root == NULL) return;
	printf("walk: %d\n", root->n);
	twalk(root->l);
	twalk(root->r);
}

void tpush(struct node **root, int n) {
	//printf("push %d\n", n);
	while (*root)
		if ((*root)->n >= n) root = &(*root)->l;
		else root = &(*root)->r;

	*root = malloc(sizeof **root);
	(*root)->n = n;
	(*root)->l = NULL;
	(*root)->r = NULL;
}

void tpop(struct node **root, int n) {
	//printf("pop %d\n", n);
	while ((*root)->n != n)
		if ((*root)->n > n) root = &(*root)->l;
		else if ((*root)->n < n) root = &(*root)->r;

	struct node *c = NULL;
	if ((*root)->l == NULL) c = (*root)->r;
	else if ((*root)->r == NULL) c = (*root)->l;
	else {
		struct node **cp = &(*root)->r;
		while ((*cp)->l) cp = &(*cp)->l;
		(*root)->n = (*cp)->n;
		struct node *rem = *cp;
		if ((*cp)->l) *cp = (*cp)->l;
		else *cp = (*cp)->r;
		free(rem);
		return;
	}

	free(*root);
	*root = c;
}

int tmin(const struct node *root) {
	if (root == NULL) return -1;
	while (root->l) root = root->l;
	return root->n;
}

int main(void) {
	int n, q;
	scanf("%d%d", &n, &q);

	for (int i = 0; i < n; i++) {
		int s, t, x;
		scanf("%d%d%d", &s, &t, &x);
		work[i*2][0] = s-x;
		work[i*2][1] = 1;
		work[i*2][2] = x;
		work[i*2+1][0] = t-x;
		work[i*2+1][1] = 0;
		work[i*2+1][2] = x;
	}
	qsort(work, 2*n, sizeof work[0], cmp);

	struct node *root = NULL;
	int ind = 0;
	for (int i = 0; i < q; i++) {
		int d;
		scanf("%d", &d);
		while (ind < 2*n && work[ind][0] <= d) {
			//printf("work[%d]: %d %d %d\n", ind, work[ind][0], work[ind][1], work[ind][2]);
			if (work[ind][1]) tpush(&root, work[ind][2]);
			else tpop(&root, work[ind][2]);
			//twalk(root);
			ind++;
		}
		printf("%d\n", tmin(root));
	}
}

4 6
1 3 2
7 13 1
18 20 13
3 4 2
0
1
2
3
5
8
 4 6
1 4 2
8 13 1
18 20 12
3 4 2
0
1
2
3
5
8
 4 5
1 4 2
8 13 1
18 20 12
3 4 2
0
1
2
3
5
8
 4 5
1 4 0
8 13 1
18 20 12
3 4 2
0
1
2
3
5
8
 4 5
0 4 0
8 13 1
18 36 9
3 4 2
0
1
2
3
5
8
 4 6
1 3 2
7 13 10
18 20 22
3 4 2
0
1
2
3
5
8
 4 5
1 4 2
8 13 1
18 20 12
3 4 2
0
1
2
3
10
8
 4 5
1 4 0
8 13 1
18 31 9
0 4 2
0
1
2
3
5
8
 4 5
1 4 1
8 13 1
18 36 9
3 4 2
0
1
2
3
5
8
 4 6
1 3 2
7 13 10
18 20 22
4 4 2
0
1
2
3
5
8

2
2
-1
-1
13
1
 2
2
-1
-1
-1
1
 2
2
-1
-1
-1
 -1
0
0
0
-1
 0
0
0
0
-1
 2
2
10
-1
-1
-1
 2
2
-1
-1
1
 2
0
0
0
-1
 1
1
1
-1
-1
 2
10
10
-1
-1
-1

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

```c
#include <stdio.h>
#include <stdlib.h>

int work[400000][3];

int cmp(const void *a, const void *b) {
	const int *ai = a, *bi = b;
	return ai[0] - bi[0];
}

struct node {
	int n;
	struct node *l, *r;
};

void twalk(const struct node *root) {
	if (root == NULL) return;
	printf("walk: %d\n", root->n);
	twalk(root->l);
	twalk(root->r);
}

void tpush(struct node **root, int n) {
	//printf("push %d\n", n);
	while (*root)
		if ((*root)->n >= n) root = &(*root)->l;
		else root = &(*root)->r;

	*root = malloc(sizeof **root);
	(*root)->n = n;
	(*root)->l = NULL;
	(*root)->r = NULL;
}

void tpop(struct node **root, int n) {
	//printf("pop %d\n", n);
	while ((*root)->n != n)
		if ((*root)->n > n) root = &(*root)->l;
		else if ((*root)->n < n) root = &(*root)->r;

	struct node *c = NULL;
	if ((*root)->l == NULL) c = (*root)->r;
	else if ((*root)->r == NULL) c = (*root)->l;
	else {
		struct node **cp = &(*root)->r;
		while ((*cp)->l) cp = &(*cp)->l;
		(*root)->n = (*cp)->n;
		struct node *rem = *cp;
		if ((*cp)->l) *cp = (*cp)->l;
		else *cp = (*cp)->r;
		free(rem);
		return;
	}

	free(*root);
	*root = c;
}

int tmin(const struct node *root) {
	if (root == NULL) return -1;
	while (root->l) root = root->l;
	return root->n;
}

int main(void) {
	int n, q;
	scanf("%d%d", &n, &q);

	for (int i = 0; i < n; i++) {
		int s, t, x;
		scanf("%d%d%d", &s, &t, &x);
		work[i*2][0] = s-x;
		work[i*2][1] = 1;
		work[i*2][2] = x;
		work[i*2+1][0] = t-x;
		work[i*2+1][1] = 0;
		work[i*2+1][2] = x;
	}
	qsort(work, 2*n, sizeof work[0], cmp);

	struct node *root = NULL;
	int ind = 0;
	for (int i = 0; i < q; i++) {
		int d;
		scanf("%d", &d);
		while (ind < 2*n && work[ind][0] <= d) {
			//printf("work[%d]: %d %d %d\n", ind, work[ind][0], work[ind][1], work[ind][2]);
			if (work[ind][1]) tpush(&root, work[ind][2]);
			else tpop(&root, work[ind][2]);
			//twalk(root);
			ind++;
		}
		printf("%d\n", tmin(root));
	}
}
```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	work
	.bss
	.align 32
	.type	work, @object
	.size	work, 4800000
work:
	.zero	4800000
	.text
	.globl	cmp
	.type	cmp, @function
cmp:
.LFB6:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movq	%rdi, -24(%rbp)
	movq	%rsi, -32(%rbp)
	movq	-24(%rbp), %rax
	movq	%rax, -16(%rbp)
	movq	-32(%rbp), %rax
	movq	%rax, -8(%rbp)
	movq	-16(%rbp), %rax
	movl	(%rax), %edx
	movq	-8(%rbp), %rax
	movl	(%rax), %ecx
	movl	%edx, %eax
	subl	%ecx, %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	cmp, .-cmp
	.section	.rodata
.LC0:
	.string	"walk: %d\n"
	.text
	.globl	twalk
	.type	twalk, @function
twalk:
.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)
	cmpq	$0, -8(%rbp)
	je	.L6
	movq	-8(%rbp), %rax
	movl	(%rax), %eax
	movl	%eax, %esi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movq	-8(%rbp), %rax
	movq	8(%rax), %rax
	movq	%rax, %rdi
	call	twalk
	movq	-8(%rbp), %rax
	movq	16(%rax), %rax
	movq	%rax, %rdi
	call	twalk
	jmp	.L3
.L6:
	nop
.L3:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.size	twalk, .-twalk
	.globl	tpush
	.type	tpush, @function
tpush:
.LFB8:
	.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)
	movl	%esi, -12(%rbp)
	jmp	.L8
.L10:
	movq	-8(%rbp), %rax
	movq	(%rax), %rax
	movl	(%rax), %eax
	cmpl	%eax, -12(%rbp)
	jg	.L9
	movq	-8(%rbp), %rax
	movq	(%rax), %rax
	addq	$8, %rax
	movq	%rax, -8(%rbp)
	jmp	.L8
.L9:
	movq	-8(%rbp), %rax
	movq	(%rax), %rax
	addq	$16, %rax
	movq	%rax, -8(%rbp)
.L8:
	movq	-8(%rbp), %rax
	movq	(%rax), %rax
	testq	%rax, %rax
	jne	.L10
	movl	$24, %edi
	call	malloc@PLT
	movq	%rax, %rdx
	movq	-8(%rbp), %rax
	movq	%rdx, (%rax)
	movq	-8(%rbp), %rax
	movq	(%rax), %rax
	movl	-12(%rbp), %edx
	movl	%edx, (%rax)
	movq	-8(%rbp), %rax
	movq	(%rax), %rax
	movq	$0, 8(%rax)
	movq	-8(%rbp), %rax
	movq	(%rax), %rax
	movq	$0, 16(%rax)
	nop
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE8:
	.size	tpush, .-tpush
	.globl	tpop
	.type	tpop, @function
tpop:
.LFB9:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$48, %rsp
	movq	%rdi, -40(%rbp)
	movl	%esi, -44(%rbp)
	jmp	.L12
.L14:
	movq	-40(%rbp), %rax
	movq	(%rax), %rax
	movl	(%rax), %eax
	cmpl	%eax, -44(%rbp)
	jge	.L13
	movq	-40(%rbp), %rax
	movq	(%rax), %rax
	addq	$8, %rax
	movq	%rax, -40(%rbp)
	jmp	.L12
.L13:
	movq	-40(%rbp), %rax
	movq	(%rax), %rax
	movl	(%rax), %eax
	cmpl	%eax, -44(%rbp)
	jle	.L12
	movq	-40(%rbp), %rax
	movq	(%rax), %rax
	addq	$16, %rax
	movq	%rax, -40(%rbp)
.L12:
	movq	-40(%rbp), %rax
	movq	(%rax), %rax
	movl	(%rax), %eax
	cmpl	%eax, -44(%rbp)
	jne	.L14
	movq	$0, -24(%rbp)
	movq	-40(%rbp), %rax
	movq	(%rax), %rax
	movq	8(%rax), %rax
	testq	%rax, %rax
	jne	.L15
	movq	-40(%rbp), %rax
	movq	(%rax), %rax
	movq	16(%rax), %rax
	movq	%rax, -24(%rbp)
	jmp	.L16
.L15:
	movq	-40(%rbp), %rax
	movq	(%rax), %rax
	movq	16(%rax), %rax
	testq	%rax, %rax
	jne	.L17
	movq	-40(%rbp), %rax
	movq	(%rax), %rax
	movq	8(%rax), %rax
	movq	%rax, -24(%rbp)
	jmp	.L16
.L17:
	movq	-40(%rbp), %rax
	movq	(%rax), %rax
	addq	$16, %rax
	movq	%rax, -16(%rbp)
	jmp	.L18
.L19:
	movq	-16(%rbp), %rax
	movq	(%rax), %rax
	addq	$8, %rax
	movq	%rax, -16(%rbp)
.L18:
	movq	-16(%rbp), %rax
	movq	(%rax), %rax
	movq	8(%rax), %rax
	testq	%rax, %rax
	jne	.L19
	movq	-16(%rbp), %rax
	movq	(%rax), %rdx
	movq	-40(%rbp), %rax
	movq	(%rax), %rax
	movl	(%rdx), %edx
	movl	%edx, (%rax)
	movq	-16(%rbp), %rax
	movq	(%rax), %rax
	movq	%rax, -8(%rbp)
	movq	-16(%rbp), %rax
	movq	(%rax), %rax
	movq	8(%rax), %rax
	testq	%rax, %rax
	je	.L20
	movq	-16(%rbp), %rax
	movq	(%rax), %rax
	movq	8(%rax), %rdx
	movq	-16(%rbp), %rax
	movq	%rdx, (%rax)
	jmp	.L21
.L20:
	movq	-16(%rbp), %rax
	movq	(%rax), %rax
	movq	16(%rax), %rdx
	movq	-16(%rbp), %rax
	movq	%rdx, (%rax)
.L21:
	movq	-8(%rbp), %rax
	movq	%rax, %rdi
	call	free@PLT
	jmp	.L11
.L16:
	movq	-40(%rbp), %rax
	movq	(%rax), %rax
	movq	%rax, %rdi
	call	free@PLT
	movq	-40(%rbp), %rax
	movq	-24(%rbp), %rdx
	movq	%rdx, (%rax)
.L11:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE9:
	.size	tpop, .-tpop
	.globl	tmin
	.type	tmin, @function
tmin:
.LFB10:
	.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)
	cmpq	$0, -8(%rbp)
	jne	.L26
	movl	$-1, %eax
	jmp	.L25
.L27:
	movq	-8(%rbp), %rax
	movq	8(%rax), %rax
	movq	%rax, -8(%rbp)
.L26:
	movq	-8(%rbp), %rax
	movq	8(%rax), %rax
	testq	%rax, %rax
	jne	.L27
	movq	-8(%rbp), %rax
	movl	(%rax), %eax
.L25:
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE10:
	.size	tmin, .-tmin
	.section	.rodata
.LC1:
	.string	"%d%d"
.LC2:
	.string	"%d%d%d"
.LC3:
	.string	"%d"
.LC4:
	.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
	subq	$48, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-40(%rbp), %rdx
	leaq	-44(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -28(%rbp)
	jmp	.L29
.L30:
	leaq	-16(%rbp), %rcx
	leaq	-32(%rbp), %rdx
	leaq	-36(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-36(%rbp), %eax
	movl	-16(%rbp), %esi
	movl	-28(%rbp), %edx
	addl	%edx, %edx
	subl	%esi, %eax
	movl	%eax, %ecx
	movslq	%edx, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	movq	%rax, %rdx
	leaq	work(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	movl	-28(%rbp), %eax
	addl	%eax, %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	movq	%rax, %rdx
	leaq	4+work(%rip), %rax
	movl	$1, (%rdx,%rax)
	movl	-28(%rbp), %eax
	addl	%eax, %eax
	movl	-16(%rbp), %edx
	movslq	%eax, %rcx
	movq	%rcx, %rax
	addq	%rax, %rax
	addq	%rcx, %rax
	salq	$2, %rax
	movq	%rax, %rcx
	leaq	8+work(%rip), %rax
	movl	%edx, (%rcx,%rax)
	movl	-32(%rbp), %eax
	movl	-16(%rbp), %esi
	movl	-28(%rbp), %edx
	addl	%edx, %edx
	addl	$1, %edx
	subl	%esi, %eax
	movl	%eax, %ecx
	movslq	%edx, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	movq	%rax, %rdx
	leaq	work(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	movl	-28(%rbp), %eax
	addl	%eax, %eax
	addl	$1, %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	movq	%rax, %rdx
	leaq	4+work(%rip), %rax
	movl	$0, (%rdx,%rax)
	movl	-28(%rbp), %eax
	addl	%eax, %eax
	addl	$1, %eax
	movl	-16(%rbp), %edx
	movslq	%eax, %rcx
	movq	%rcx, %rax
	addq	%rax, %rax
	addq	%rcx, %rax
	salq	$2, %rax
	movq	%rax, %rcx
	leaq	8+work(%rip), %rax
	movl	%edx, (%rcx,%rax)
	addl	$1, -28(%rbp)
.L29:
	movl	-44(%rbp), %eax
	cmpl	%eax, -28(%rbp)
	jl	.L30
	movl	-44(%rbp), %eax
	addl	%eax, %eax
	cltq
	leaq	cmp(%rip), %rdx
	movq	%rdx, %rcx
	movl	$12, %edx
	movq	%rax, %rsi
	leaq	work(%rip), %rax
	movq	%rax, %rdi
	call	qsort@PLT
	movq	$0, -16(%rbp)
	movl	$0, -24(%rbp)
	movl	$0, -20(%rbp)
	jmp	.L31
.L37:
	leaq	-32(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	jmp	.L32
.L36:
	movl	-24(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	movq	%rax, %rdx
	leaq	4+work(%rip), %rax
	movl	(%rdx,%rax), %eax
	testl	%eax, %eax
	je	.L33
	movl	-24(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	movq	%rax, %rdx
	leaq	8+work(%rip), %rax
	movl	(%rdx,%rax), %edx
	leaq	-16(%rbp), %rax
	movl	%edx, %esi
	movq	%rax, %rdi
	call	tpush
	jmp	.L34
.L33:
	movl	-24(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	movq	%rax, %rdx
	leaq	8+work(%rip), %rax
	movl	(%rdx,%rax), %edx
	leaq	-16(%rbp), %rax
	movl	%edx, %esi
	movq	%rax, %rdi
	call	tpop
.L34:
	addl	$1, -24(%rbp)
.L32:
	movl	-44(%rbp), %eax
	addl	%eax, %eax
	cmpl	%eax, -24(%rbp)
	jge	.L35
	movl	-24(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	movq	%rax, %rdx
	leaq	work(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-32(%rbp), %eax
	cmpl	%eax, %edx
	jle	.L36
.L35:
	movq	-16(%rbp), %rax
	movq	%rax, %rdi
	call	tmin
	movl	%eax, %esi
	leaq	.LC4(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	addl	$1, -20(%rbp)
.L31:
	movl	-40(%rbp), %eax
	cmpl	%eax, -20(%rbp)
	jl	.L37
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L39
	call	__stack_chk_fail@PLT
.L39:
	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
	.globl	work
	.bss
	.align 32
	.type	work, @object
	.size	work, 4800000
work:
	.zero	4800000
	.text
	.globl	cmp
	.type	cmp, @function
cmp:
.LFB6:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movq	%rdi, -24(%rbp)
	movq	%rsi, -32(%rbp)
	movq	-24(%rbp), %rax
	movq	%rax, -16(%rbp)
	movq	-32(%rbp), %rax
	movq	%rax, -8(%rbp)
	movq	-16(%rbp), %rax
	movl	(%rax), %edx
	movq	-8(%rbp), %rax
	movl	(%rax), %ecx
	movl	%edx, %eax
	subl	%ecx, %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	cmp, .-cmp
	.section	.rodata
.LC0:
	.string	"walk: %d\n"
	.text
	.globl	twalk
	.type	twalk, @function
twalk:
.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)
	cmpq	$0, -8(%rbp)
	je	.L6
	movq	-8(%rbp), %rax
	movl	(%rax), %eax
	movl	%eax, %esi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movq	-8(%rbp), %rax
	movq	8(%rax), %rax
	movq	%rax, %rdi
	call	twalk
	movq	-8(%rbp), %rax
	movq	16(%rax), %rax
	movq	%rax, %rdi
	call	twalk
	jmp	.L3
.L6:
	nop
.L3:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.size	twalk, .-twalk
	.globl	tpush
	.type	tpush, @function
tpush:
.LFB8:
	.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)
	movl	%esi, -12(%rbp)
	jmp	.L8
.L10:
	movq	-8(%rbp), %rax
	movq	(%rax), %rax
	movl	(%rax), %eax
	cmpl	%eax, -12(%rbp)
	jg	.L9
	movq	-8(%rbp), %rax
	movq	(%rax), %rax
	addq	$8, %rax
	movq	%rax, -8(%rbp)
	jmp	.L8
.L9:
	movq	-8(%rbp), %rax
	movq	(%rax), %rax
	addq	$16, %rax
	movq	%rax, -8(%rbp)
.L8:
	movq	-8(%rbp), %rax
	movq	(%rax), %rax
	testq	%rax, %rax
	jne	.L10
	movl	$24, %edi
	call	malloc@PLT
	movq	%rax, %rdx
	movq	-8(%rbp), %rax
	movq	%rdx, (%rax)
	movq	-8(%rbp), %rax
	movq	(%rax), %rax
	movl	-12(%rbp), %edx
	movl	%edx, (%rax)
	movq	-8(%rbp), %rax
	movq	(%rax), %rax
	movq	$0, 8(%rax)
	movq	-8(%rbp), %rax
	movq	(%rax), %rax
	movq	$0, 16(%rax)
	nop
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE8:
	.size	tpush, .-tpush
	.globl	tpop
	.type	tpop, @function
tpop:
.LFB9:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$48, %rsp
	movq	%rdi, -40(%rbp)
	movl	%esi, -44(%rbp)
	jmp	.L12
.L14:
	movq	-40(%rbp), %rax
	movq	(%rax), %rax
	movl	(%rax), %eax
	cmpl	%eax, -44(%rbp)
	jge	.L13
	movq	-40(%rbp), %rax
	movq	(%rax), %rax
	addq	$8, %rax
	movq	%rax, -40(%rbp)
	jmp	.L12
.L13:
	movq	-40(%rbp), %rax
	movq	(%rax), %rax
	movl	(%rax), %eax
	cmpl	%eax, -44(%rbp)
	jle	.L12
	movq	-40(%rbp), %rax
	movq	(%rax), %rax
	addq	$16, %rax
	movq	%rax, -40(%rbp)
.L12:
	movq	-40(%rbp), %rax
	movq	(%rax), %rax
	movl	(%rax), %eax
	cmpl	%eax, -44(%rbp)
	jne	.L14
	movq	$0, -24(%rbp)
	movq	-40(%rbp), %rax
	movq	(%rax), %rax
	movq	8(%rax), %rax
	testq	%rax, %rax
	jne	.L15
	movq	-40(%rbp), %rax
	movq	(%rax), %rax
	movq	16(%rax), %rax
	movq	%rax, -24(%rbp)
	jmp	.L16
.L15:
	movq	-40(%rbp), %rax
	movq	(%rax), %rax
	movq	16(%rax), %rax
	testq	%rax, %rax
	jne	.L17
	movq	-40(%rbp), %rax
	movq	(%rax), %rax
	movq	8(%rax), %rax
	movq	%rax, -24(%rbp)
	jmp	.L16
.L17:
	movq	-40(%rbp), %rax
	movq	(%rax), %rax
	addq	$16, %rax
	movq	%rax, -16(%rbp)
	jmp	.L18
.L19:
	movq	-16(%rbp), %rax
	movq	(%rax), %rax
	addq	$8, %rax
	movq	%rax, -16(%rbp)
.L18:
	movq	-16(%rbp), %rax
	movq	(%rax), %rax
	movq	8(%rax), %rax
	testq	%rax, %rax
	jne	.L19
	movq	-16(%rbp), %rax
	movq	(%rax), %rdx
	movq	-40(%rbp), %rax
	movq	(%rax), %rax
	movl	(%rdx), %edx
	movl	%edx, (%rax)
	movq	-16(%rbp), %rax
	movq	(%rax), %rax
	movq	%rax, -8(%rbp)
	movq	-16(%rbp), %rax
	movq	(%rax), %rax
	movq	8(%rax), %rax
	testq	%rax, %rax
	je	.L20
	movq	-16(%rbp), %rax
	movq	(%rax), %rax
	movq	8(%rax), %rdx
	movq	-16(%rbp), %rax
	movq	%rdx, (%rax)
	jmp	.L21
.L20:
	movq	-16(%rbp), %rax
	movq	(%rax), %rax
	movq	16(%rax), %rdx
	movq	-16(%rbp), %rax
	movq	%rdx, (%rax)
.L21:
	movq	-8(%rbp), %rax
	movq	%rax, %rdi
	call	free@PLT
	jmp	.L11
.L16:
	movq	-40(%rbp), %rax
	movq	(%rax), %rax
	movq	%rax, %rdi
	call	free@PLT
	movq	-40(%rbp), %rax
	movq	-24(%rbp), %rdx
	movq	%rdx, (%rax)
.L11:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE9:
	.size	tpop, .-tpop
	.globl	tmin
	.type	tmin, @function
tmin:
.LFB10:
	.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)
	cmpq	$0, -8(%rbp)
	jne	.L26
	movl	$-1, %eax
	jmp	.L25
.L27:
	movq	-8(%rbp), %rax
	movq	8(%rax), %rax
	movq	%rax, -8(%rbp)
.L26:
	movq	-8(%rbp), %rax
	movq	8(%rax), %rax
	testq	%rax, %rax
	jne	.L27
	movq	-8(%rbp), %rax
	movl	(%rax), %eax
.L25:
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE10:
	.size	tmin, .-tmin
	.section	.rodata
.LC1:
	.string	"%d%d"
.LC2:
	.string	"%d%d%d"
.LC3:
	.string	"%d"
.LC4:
	.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
	subq	$48, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-40(%rbp), %rdx
	leaq	-44(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -28(%rbp)
	jmp	.L29
.L30:
	leaq	-16(%rbp), %rcx
	leaq	-32(%rbp), %rdx
	leaq	-36(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-36(%rbp), %eax
	movl	-16(%rbp), %esi
	movl	-28(%rbp), %edx
	addl	%edx, %edx
	subl	%esi, %eax
	movl	%eax, %ecx
	movslq	%edx, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	movq	%rax, %rdx
	leaq	work(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	movl	-28(%rbp), %eax
	addl	%eax, %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	movq	%rax, %rdx
	leaq	4+work(%rip), %rax
	movl	$1, (%rdx,%rax)
	movl	-28(%rbp), %eax
	addl	%eax, %eax
	movl	-16(%rbp), %edx
	movslq	%eax, %rcx
	movq	%rcx, %rax
	addq	%rax, %rax
	addq	%rcx, %rax
	salq	$2, %rax
	movq	%rax, %rcx
	leaq	8+work(%rip), %rax
	movl	%edx, (%rcx,%rax)
	movl	-32(%rbp), %eax
	movl	-16(%rbp), %esi
	movl	-28(%rbp), %edx
	addl	%edx, %edx
	addl	$1, %edx
	subl	%esi, %eax
	movl	%eax, %ecx
	movslq	%edx, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	movq	%rax, %rdx
	leaq	work(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	movl	-28(%rbp), %eax
	addl	%eax, %eax
	addl	$1, %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	movq	%rax, %rdx
	leaq	4+work(%rip), %rax
	movl	$0, (%rdx,%rax)
	movl	-28(%rbp), %eax
	addl	%eax, %eax
	addl	$1, %eax
	movl	-16(%rbp), %edx
	movslq	%eax, %rcx
	movq	%rcx, %rax
	addq	%rax, %rax
	addq	%rcx, %rax
	salq	$2, %rax
	movq	%rax, %rcx
	leaq	8+work(%rip), %rax
	movl	%edx, (%rcx,%rax)
	addl	$1, -28(%rbp)
.L29:
	movl	-44(%rbp), %eax
	cmpl	%eax, -28(%rbp)
	jl	.L30
	movl	-44(%rbp), %eax
	addl	%eax, %eax
	cltq
	leaq	cmp(%rip), %rdx
	movq	%rdx, %rcx
	movl	$12, %edx
	movq	%rax, %rsi
	leaq	work(%rip), %rax
	movq	%rax, %rdi
	call	qsort@PLT
	movq	$0, -16(%rbp)
	movl	$0, -24(%rbp)
	movl	$0, -20(%rbp)
	jmp	.L31
.L37:
	leaq	-32(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	jmp	.L32
.L36:
	movl	-24(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	movq	%rax, %rdx
	leaq	4+work(%rip), %rax
	movl	(%rdx,%rax), %eax
	testl	%eax, %eax
	je	.L33
	movl	-24(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	movq	%rax, %rdx
	leaq	8+work(%rip), %rax
	movl	(%rdx,%rax), %edx
	leaq	-16(%rbp), %rax
	movl	%edx, %esi
	movq	%rax, %rdi
	call	tpush
	jmp	.L34
.L33:
	movl	-24(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	movq	%rax, %rdx
	leaq	8+work(%rip), %rax
	movl	(%rdx,%rax), %edx
	leaq	-16(%rbp), %rax
	movl	%edx, %esi
	movq	%rax, %rdi
	call	tpop
.L34:
	addl	$1, -24(%rbp)
.L32:
	movl	-44(%rbp), %eax
	addl	%eax, %eax
	cmpl	%eax, -24(%rbp)
	jge	.L35
	movl	-24(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	movq	%rax, %rdx
	leaq	work(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-32(%rbp), %eax
	cmpl	%eax, %edx
	jle	.L36
.L35:
	movq	-16(%rbp), %rax
	movq	%rax, %rdi
	call	tmin
	movl	%eax, %esi
	leaq	.LC4(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	addl	$1, -20(%rbp)
.L31:
	movl	-40(%rbp), %eax
	cmpl	%eax, -20(%rbp)
	jl	.L37
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L39
	call	__stack_chk_fail@PLT
.L39:
	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:
