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

```c
// AOJ DSL_3_B The Smallest Window II
// 2018.5.6 bal4u@uu

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#if 1
#define gc() getchar_unlocked()
#else
#define gc() getchar()
#endif
int in()
{
	int n = 0, c = gc();
	do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

#define MAX_N 100003
int a[MAX_N], f[MAX_N];

int main()
{
	int N, K, i, j, s, t, ans;

	N = in(), K = in();
	if (N < K) { puts("0"); return 0; }
	for (i = 0; i < N; i++) a[i] = in();

	s = 0, i = j = 0;
	while (s < K && j < N) {
		t = a[j++];
		if (t <= K) { if (f[t] == 0) s++; f[t]++; }
	}
	if (s < K) { puts("0"); return 0; }
	while ((t = a[i]) > K || f[t] > 1) { i++; if (t <= K) f[t]--; }
	ans = j-i;

	while (j < N) {
		if ((t = a[j++]) <= K) f[t]++;
		while ((t = a[i]) > K || f[t] > 1) { i++; if (t <= K) f[t]--; }
		if (j-i < ans) ans = j-i;
	}
	printf("%d\n", ans);
	return 0;
}

```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	in
	.type	in, @function
in:
.LFB6:
	.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
	movl	$0, -8(%rbp)
	call	getchar_unlocked@PLT
	movl	%eax, -4(%rbp)
.L2:
	movl	-8(%rbp), %edx
	movl	%edx, %eax
	sall	$2, %eax
	addl	%edx, %eax
	addl	%eax, %eax
	movl	%eax, %edx
	movl	-4(%rbp), %eax
	andl	$15, %eax
	addl	%edx, %eax
	movl	%eax, -8(%rbp)
	call	getchar_unlocked@PLT
	movl	%eax, -4(%rbp)
	cmpl	$47, -4(%rbp)
	jg	.L2
	movl	-8(%rbp), %eax
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	in, .-in
	.globl	a
	.bss
	.align 32
	.type	a, @object
	.size	a, 400012
a:
	.zero	400012
	.globl	f
	.align 32
	.type	f, @object
	.size	f, 400012
f:
	.zero	400012
	.section	.rodata
.LC0:
	.string	"0"
.LC1:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB7:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$32, %rsp
	movl	$0, %eax
	call	in
	movl	%eax, -12(%rbp)
	movl	$0, %eax
	call	in
	movl	%eax, -8(%rbp)
	movl	-12(%rbp), %eax
	cmpl	-8(%rbp), %eax
	jge	.L5
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	movl	$0, %eax
	jmp	.L6
.L5:
	movl	$0, -28(%rbp)
	jmp	.L7
.L8:
	movl	$0, %eax
	call	in
	movl	-28(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	a(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	addl	$1, -28(%rbp)
.L7:
	movl	-28(%rbp), %eax
	cmpl	-12(%rbp), %eax
	jl	.L8
	movl	$0, -20(%rbp)
	movl	$0, -24(%rbp)
	movl	-24(%rbp), %eax
	movl	%eax, -28(%rbp)
	jmp	.L9
.L12:
	movl	-24(%rbp), %eax
	leal	1(%rax), %edx
	movl	%edx, -24(%rbp)
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -4(%rbp)
	movl	-4(%rbp), %eax
	cmpl	-8(%rbp), %eax
	jg	.L9
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	f(%rip), %rax
	movl	(%rdx,%rax), %eax
	testl	%eax, %eax
	jne	.L10
	addl	$1, -20(%rbp)
.L10:
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	f(%rip), %rax
	movl	(%rdx,%rax), %eax
	leal	1(%rax), %ecx
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	f(%rip), %rax
	movl	%ecx, (%rdx,%rax)
.L9:
	movl	-20(%rbp), %eax
	cmpl	-8(%rbp), %eax
	jge	.L11
	movl	-24(%rbp), %eax
	cmpl	-12(%rbp), %eax
	jl	.L12
.L11:
	movl	-20(%rbp), %eax
	cmpl	-8(%rbp), %eax
	jge	.L14
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	movl	$0, %eax
	jmp	.L6
.L15:
	addl	$1, -28(%rbp)
	movl	-4(%rbp), %eax
	cmpl	-8(%rbp), %eax
	jg	.L14
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	f(%rip), %rax
	movl	(%rdx,%rax), %eax
	leal	-1(%rax), %ecx
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	f(%rip), %rax
	movl	%ecx, (%rdx,%rax)
.L14:
	movl	-28(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -4(%rbp)
	movl	-4(%rbp), %eax
	cmpl	-8(%rbp), %eax
	jg	.L15
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	f(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	$1, %eax
	jg	.L15
	movl	-24(%rbp), %eax
	subl	-28(%rbp), %eax
	movl	%eax, -16(%rbp)
	jmp	.L16
.L20:
	movl	-24(%rbp), %eax
	leal	1(%rax), %edx
	movl	%edx, -24(%rbp)
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -4(%rbp)
	movl	-4(%rbp), %eax
	cmpl	-8(%rbp), %eax
	jg	.L18
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	f(%rip), %rax
	movl	(%rdx,%rax), %eax
	leal	1(%rax), %ecx
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	f(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	jmp	.L18
.L19:
	addl	$1, -28(%rbp)
	movl	-4(%rbp), %eax
	cmpl	-8(%rbp), %eax
	jg	.L18
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	f(%rip), %rax
	movl	(%rdx,%rax), %eax
	leal	-1(%rax), %ecx
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	f(%rip), %rax
	movl	%ecx, (%rdx,%rax)
.L18:
	movl	-28(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -4(%rbp)
	movl	-4(%rbp), %eax
	cmpl	-8(%rbp), %eax
	jg	.L19
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	f(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	$1, %eax
	jg	.L19
	movl	-24(%rbp), %eax
	subl	-28(%rbp), %eax
	cmpl	%eax, -16(%rbp)
	jle	.L16
	movl	-24(%rbp), %eax
	subl	-28(%rbp), %eax
	movl	%eax, -16(%rbp)
.L16:
	movl	-24(%rbp), %eax
	cmpl	-12(%rbp), %eax
	jl	.L20
	movl	-16(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
.L6:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.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	in
	.type	in, @function
in:
.LFB51:
	.cfi_startproc
	endbr64
	movq	stdin(%rip), %rdi
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	movq	8(%rdi), %rax
	movq	16(%rdi), %rcx
	cmpq	%rcx, %rax
	jnb	.L11
	leaq	1(%rax), %rdx
	movq	%rdx, 8(%rdi)
	movzbl	(%rax), %eax
.L3:
	xorl	%r12d, %r12d
	jmp	.L7
	.p2align 4,,10
	.p2align 3
.L4:
	leaq	1(%rdx), %rax
	movq	%rax, 8(%rdi)
	movzbl	(%rdx), %eax
	cmpl	$47, %eax
	jle	.L1
.L5:
	movq	8(%rdi), %rdx
	movq	16(%rdi), %rcx
.L7:
	leal	(%r12,%r12,4), %esi
	andl	$15, %eax
	leal	(%rax,%rsi,2), %r12d
	cmpq	%rcx, %rdx
	jb	.L4
	call	__uflow@PLT
	cmpl	$47, %eax
	jle	.L1
	movq	stdin(%rip), %rdi
	jmp	.L5
	.p2align 4,,10
	.p2align 3
.L1:
	movl	%r12d, %eax
	popq	%r12
	.cfi_remember_state
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L11:
	.cfi_restore_state
	call	__uflow@PLT
	movq	stdin(%rip), %rdi
	movq	8(%rdi), %rdx
	movq	16(%rdi), %rcx
	jmp	.L3
	.cfi_endproc
.LFE51:
	.size	in, .-in
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"0"
.LC1:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB52:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	xorl	%eax, %eax
	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	$8, %rsp
	.cfi_def_cfa_offset 64
	call	in
	movl	%eax, %ebx
	xorl	%eax, %eax
	call	in
	cmpl	%eax, %ebx
	jl	.L13
	movl	%eax, %r12d
	xorl	%edi, %edi
	xorl	%esi, %esi
	testl	%ebx, %ebx
	jle	.L15
	leaq	a(%rip), %r13
	leal	-1(%rbx), %eax
	leaq	4(%r13), %rdx
	movq	%r13, %r15
	leaq	(%rdx,%rax,4), %rbp
	.p2align 4,,10
	.p2align 3
.L23:
	movq	stdin(%rip), %rdi
	movq	8(%rdi), %rax
	movq	16(%rdi), %rcx
	cmpq	%rcx, %rax
	jnb	.L45
	leaq	1(%rax), %rdx
	movq	%rdx, 8(%rdi)
	movzbl	(%rax), %eax
.L18:
	xorl	%r14d, %r14d
	jmp	.L22
	.p2align 4,,10
	.p2align 3
.L19:
	leaq	1(%rdx), %rax
	movq	%rax, 8(%rdi)
	movzbl	(%rdx), %eax
	cmpl	$47, %eax
	jle	.L21
.L20:
	movq	8(%rdi), %rdx
	movq	16(%rdi), %rcx
.L22:
	leal	(%r14,%r14,4), %esi
	andl	$15, %eax
	leal	(%rax,%rsi,2), %r14d
	cmpq	%rcx, %rdx
	jb	.L19
	call	__uflow@PLT
	cmpl	$47, %eax
	jle	.L21
	movq	stdin(%rip), %rdi
	jmp	.L20
	.p2align 4,,10
	.p2align 3
.L21:
	movl	%r14d, (%r15)
	addq	$4, %r15
	cmpq	%r15, %rbp
	jne	.L23
	testl	%r12d, %r12d
	jle	.L38
	movl	$1, %eax
	xorl	%edi, %edi
	leaq	-4+a(%rip), %r10
	leaq	f(%rip), %r8
	.p2align 4,,10
	.p2align 3
.L27:
	movslq	(%r10,%rax,4), %rdx
	movl	%eax, %esi
	cmpl	%edx, %r12d
	jl	.L25
	movl	(%r8,%rdx,4), %ecx
	cmpl	$1, %ecx
	adcl	$0, %edi
	addl	$1, %ecx
	movl	%ecx, (%r8,%rdx,4)
.L25:
	cmpl	%edi, %r12d
	setg	%cl
	cmpl	%eax, %ebx
	setg	%dl
	addq	$1, %rax
	testb	%dl, %cl
	jne	.L27
.L15:
	leaq	a(%rip), %r13
	cmpl	%edi, %r12d
	jg	.L13
.L24:
	xorl	%eax, %eax
	leaq	f(%rip), %r8
	jmp	.L28
	.p2align 4,,10
	.p2align 3
.L30:
	subl	$1, %ecx
	movl	%ecx, (%r8,%r9,4)
.L29:
	addq	$1, %rax
.L28:
	movl	0(%r13,%rax,4), %edx
	movl	%eax, %edi
	cmpl	%edx, %r12d
	jl	.L29
	movslq	%edx, %r9
	movl	(%r8,%r9,4), %ecx
	cmpl	$1, %ecx
	jg	.L30
	movl	%esi, %r11d
	subl	%eax, %r11d
	cmpl	%esi, %ebx
	jle	.L31
	subl	$1, %ebx
	leal	2(%rsi), %eax
	leal	1(%rsi), %r9d
	subl	%esi, %ebx
	cltq
	leaq	-4+a(%rip), %r10
	movslq	%r9d, %r9
	addq	%rax, %rbx
	.p2align 4,,10
	.p2align 3
.L36:
	movslq	(%r10,%r9,4), %rax
	movl	%r9d, %ebp
	cmpl	%eax, %r12d
	jl	.L32
	addl	$1, (%r8,%rax,4)
.L32:
	leal	1(%rdi), %eax
	jmp	.L33
	.p2align 4,,10
	.p2align 3
.L35:
	subl	$1, %ecx
	movl	%ecx, (%r8,%rsi,4)
.L37:
	movslq	%eax, %rdx
	addl	$1, %eax
	movl	0(%r13,%rdx,4), %edx
.L33:
	leal	-1(%rax), %edi
	cmpl	%edx, %r12d
	jl	.L37
	movslq	%edx, %rsi
	movl	(%r8,%rsi,4), %ecx
	cmpl	$1, %ecx
	jg	.L35
	movl	%ebp, %eax
	subl	%edi, %eax
	cmpl	%eax, %r11d
	cmovg	%eax, %r11d
	addq	$1, %r9
	cmpq	%r9, %rbx
	jne	.L36
.L31:
	movl	%r11d, %edx
	leaq	.LC1(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L43:
	addq	$8, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 56
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
.L45:
	.cfi_restore_state
	call	__uflow@PLT
	movq	stdin(%rip), %rdi
	movq	8(%rdi), %rdx
	movq	16(%rdi), %rcx
	jmp	.L18
.L13:
	leaq	.LC0(%rip), %rdi
	call	puts@PLT
	jmp	.L43
.L38:
	xorl	%esi, %esi
	jmp	.L24
	.cfi_endproc
.LFE52:
	.size	main, .-main
	.globl	f
	.bss
	.align 32
	.type	f, @object
	.size	f, 400012
f:
	.zero	400012
	.globl	a
	.align 32
	.type	a, @object
	.size	a, 400012
a:
	.zero	400012
	.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	in
	.type	in, @function
in:
.LFB51:
	.cfi_startproc
	endbr64
	movq	stdin(%rip), %rdi
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	movq	8(%rdi), %rax
	movq	16(%rdi), %rcx
	cmpq	%rcx, %rax
	jnb	.L11
	leaq	1(%rax), %rdx
	movq	%rdx, 8(%rdi)
	movzbl	(%rax), %eax
.L3:
	xorl	%r12d, %r12d
	jmp	.L7
	.p2align 4,,10
	.p2align 3
.L4:
	leaq	1(%rdx), %rax
	movq	%rax, 8(%rdi)
	movzbl	(%rdx), %eax
	cmpl	$47, %eax
	jle	.L1
.L5:
	movq	8(%rdi), %rdx
	movq	16(%rdi), %rcx
.L7:
	leal	(%r12,%r12,4), %esi
	andl	$15, %eax
	leal	(%rax,%rsi,2), %r12d
	cmpq	%rcx, %rdx
	jb	.L4
	call	__uflow@PLT
	cmpl	$47, %eax
	jle	.L1
	movq	stdin(%rip), %rdi
	jmp	.L5
	.p2align 4,,10
	.p2align 3
.L1:
	movl	%r12d, %eax
	popq	%r12
	.cfi_remember_state
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L11:
	.cfi_restore_state
	call	__uflow@PLT
	movq	stdin(%rip), %rdi
	movq	8(%rdi), %rdx
	movq	16(%rdi), %rcx
	jmp	.L3
	.cfi_endproc
.LFE51:
	.size	in, .-in
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"0"
.LC1:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB52:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	xorl	%eax, %eax
	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	$8, %rsp
	.cfi_def_cfa_offset 64
	call	in
	movl	%eax, %ebx
	xorl	%eax, %eax
	call	in
	cmpl	%eax, %ebx
	jl	.L13
	movl	%eax, %r12d
	xorl	%edi, %edi
	xorl	%esi, %esi
	testl	%ebx, %ebx
	jle	.L15
	leaq	a(%rip), %r13
	leal	-1(%rbx), %eax
	leaq	4(%r13), %rdx
	movq	%r13, %r15
	leaq	(%rdx,%rax,4), %rbp
	.p2align 4,,10
	.p2align 3
.L23:
	movq	stdin(%rip), %rdi
	movq	8(%rdi), %rax
	movq	16(%rdi), %rcx
	cmpq	%rcx, %rax
	jnb	.L45
	leaq	1(%rax), %rdx
	movq	%rdx, 8(%rdi)
	movzbl	(%rax), %eax
.L18:
	xorl	%r14d, %r14d
	jmp	.L22
	.p2align 4,,10
	.p2align 3
.L19:
	leaq	1(%rdx), %rax
	movq	%rax, 8(%rdi)
	movzbl	(%rdx), %eax
	cmpl	$47, %eax
	jle	.L21
.L20:
	movq	8(%rdi), %rdx
	movq	16(%rdi), %rcx
.L22:
	leal	(%r14,%r14,4), %esi
	andl	$15, %eax
	leal	(%rax,%rsi,2), %r14d
	cmpq	%rcx, %rdx
	jb	.L19
	call	__uflow@PLT
	cmpl	$47, %eax
	jle	.L21
	movq	stdin(%rip), %rdi
	jmp	.L20
	.p2align 4,,10
	.p2align 3
.L21:
	movl	%r14d, (%r15)
	addq	$4, %r15
	cmpq	%r15, %rbp
	jne	.L23
	testl	%r12d, %r12d
	jle	.L38
	movl	$1, %eax
	xorl	%edi, %edi
	leaq	-4+a(%rip), %r10
	leaq	f(%rip), %r8
	.p2align 4,,10
	.p2align 3
.L27:
	movslq	(%r10,%rax,4), %rdx
	movl	%eax, %esi
	cmpl	%edx, %r12d
	jl	.L25
	movl	(%r8,%rdx,4), %ecx
	cmpl	$1, %ecx
	adcl	$0, %edi
	addl	$1, %ecx
	movl	%ecx, (%r8,%rdx,4)
.L25:
	cmpl	%edi, %r12d
	setg	%cl
	cmpl	%eax, %ebx
	setg	%dl
	addq	$1, %rax
	testb	%dl, %cl
	jne	.L27
.L15:
	leaq	a(%rip), %r13
	cmpl	%edi, %r12d
	jg	.L13
.L24:
	xorl	%eax, %eax
	leaq	f(%rip), %r8
	jmp	.L28
	.p2align 4,,10
	.p2align 3
.L30:
	subl	$1, %ecx
	movl	%ecx, (%r8,%r9,4)
.L29:
	addq	$1, %rax
.L28:
	movl	0(%r13,%rax,4), %edx
	movl	%eax, %edi
	cmpl	%edx, %r12d
	jl	.L29
	movslq	%edx, %r9
	movl	(%r8,%r9,4), %ecx
	cmpl	$1, %ecx
	jg	.L30
	movl	%esi, %r11d
	subl	%eax, %r11d
	cmpl	%esi, %ebx
	jle	.L31
	subl	$1, %ebx
	leal	2(%rsi), %eax
	leal	1(%rsi), %r9d
	subl	%esi, %ebx
	cltq
	leaq	-4+a(%rip), %r10
	movslq	%r9d, %r9
	addq	%rax, %rbx
	.p2align 4,,10
	.p2align 3
.L36:
	movslq	(%r10,%r9,4), %rax
	movl	%r9d, %ebp
	cmpl	%eax, %r12d
	jl	.L32
	addl	$1, (%r8,%rax,4)
.L32:
	leal	1(%rdi), %eax
	jmp	.L33
	.p2align 4,,10
	.p2align 3
.L35:
	subl	$1, %ecx
	movl	%ecx, (%r8,%rsi,4)
.L37:
	movslq	%eax, %rdx
	addl	$1, %eax
	movl	0(%r13,%rdx,4), %edx
.L33:
	leal	-1(%rax), %edi
	cmpl	%edx, %r12d
	jl	.L37
	movslq	%edx, %rsi
	movl	(%r8,%rsi,4), %ecx
	cmpl	$1, %ecx
	jg	.L35
	movl	%ebp, %eax
	subl	%edi, %eax
	cmpl	%eax, %r11d
	cmovg	%eax, %r11d
	addq	$1, %r9
	cmpq	%r9, %rbx
	jne	.L36
.L31:
	movl	%r11d, %edx
	leaq	.LC1(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L43:
	addq	$8, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 56
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
.L45:
	.cfi_restore_state
	call	__uflow@PLT
	movq	stdin(%rip), %rdi
	movq	8(%rdi), %rdx
	movq	16(%rdi), %rcx
	jmp	.L18
.L13:
	leaq	.LC0(%rip), %rdi
	call	puts@PLT
	jmp	.L43
.L38:
	xorl	%esi, %esi
	jmp	.L24
	.cfi_endproc
.LFE52:
	.size	main, .-main
	.globl	f
	.bss
	.align 32
	.type	f, @object
	.size	f, 400012
f:
	.zero	400012
	.globl	a
	.align 32
	.type	a, @object
	.size	a, 400012
a:
	.zero	400012
	.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:

// AOJ DSL_3_B The Smallest Window II
// 2018.5.6 bal4u@uu

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#if 1
#define gc() getchar_unlocked()
#else
#define gc() getchar()
#endif
int in()
{
	int n = 0, c = gc();
	do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

#define MAX_N 100003
int a[MAX_N], f[MAX_N];

int main()
{
	int N, K, i, j, s, t, ans;

	N = in(), K = in();
	if (N < K) { puts("0"); return 0; }
	for (i = 0; i < N; i++) a[i] = in();

	s = 0, i = j = 0;
	while (s < K && j < N) {
		t = a[j++];
		if (t <= K) { if (f[t] == 0) s++; f[t]++; }
	}
	if (s < K) { puts("0"); return 0; }
	while ((t = a[i]) > K || f[t] > 1) { i++; if (t <= K) f[t]--; }
	ans = j-i;

	while (j < N) {
		if ((t = a[j++]) <= K) f[t]++;
		while ((t = a[i]) > K || f[t] > 1) { i++; if (t <= K) f[t]--; }
		if (j-i < ans) ans = j-i;
	}
	printf("%d\n", ans);
	return 0;
}


0 4
1 2 3
 6 3
4 1 2 1 3 8
 6 2
4 1 2 2 3 5
 6 4
4 1 0 1 4 2
 7 4
4 1 0 0 13 2
 7 1
1 1 0 0 13 2
 9 3
4 2 2 1 5 16
 7 4
4 1 1 1 5 2
 1 4
1 2 3
 9 3
4 1 2 1 3 8

0
 3
 2
 4
 6
 1
 0
 0
 0
 3

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

```c
// AOJ DSL_3_B The Smallest Window II
// 2018.5.6 bal4u@uu

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#if 1
#define gc() getchar_unlocked()
#else
#define gc() getchar()
#endif
int in()
{
	int n = 0, c = gc();
	do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

#define MAX_N 100003
int a[MAX_N], f[MAX_N];

int main()
{
	int N, K, i, j, s, t, ans;

	N = in(), K = in();
	if (N < K) { puts("0"); return 0; }
	for (i = 0; i < N; i++) a[i] = in();

	s = 0, i = j = 0;
	while (s < K && j < N) {
		t = a[j++];
		if (t <= K) { if (f[t] == 0) s++; f[t]++; }
	}
	if (s < K) { puts("0"); return 0; }
	while ((t = a[i]) > K || f[t] > 1) { i++; if (t <= K) f[t]--; }
	ans = j-i;

	while (j < N) {
		if ((t = a[j++]) <= K) f[t]++;
		while ((t = a[i]) > K || f[t] > 1) { i++; if (t <= K) f[t]--; }
		if (j-i < ans) ans = j-i;
	}
	printf("%d\n", ans);
	return 0;
}

```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	in
	.type	in, @function
in:
.LFB6:
	.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
	movl	$0, -8(%rbp)
	call	getchar_unlocked@PLT
	movl	%eax, -4(%rbp)
.L2:
	movl	-8(%rbp), %edx
	movl	%edx, %eax
	sall	$2, %eax
	addl	%edx, %eax
	addl	%eax, %eax
	movl	%eax, %edx
	movl	-4(%rbp), %eax
	andl	$15, %eax
	addl	%edx, %eax
	movl	%eax, -8(%rbp)
	call	getchar_unlocked@PLT
	movl	%eax, -4(%rbp)
	cmpl	$47, -4(%rbp)
	jg	.L2
	movl	-8(%rbp), %eax
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	in, .-in
	.globl	a
	.bss
	.align 32
	.type	a, @object
	.size	a, 400012
a:
	.zero	400012
	.globl	f
	.align 32
	.type	f, @object
	.size	f, 400012
f:
	.zero	400012
	.section	.rodata
.LC0:
	.string	"0"
.LC1:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB7:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$32, %rsp
	movl	$0, %eax
	call	in
	movl	%eax, -12(%rbp)
	movl	$0, %eax
	call	in
	movl	%eax, -8(%rbp)
	movl	-12(%rbp), %eax
	cmpl	-8(%rbp), %eax
	jge	.L5
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	movl	$0, %eax
	jmp	.L6
.L5:
	movl	$0, -28(%rbp)
	jmp	.L7
.L8:
	movl	$0, %eax
	call	in
	movl	-28(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	a(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	addl	$1, -28(%rbp)
.L7:
	movl	-28(%rbp), %eax
	cmpl	-12(%rbp), %eax
	jl	.L8
	movl	$0, -20(%rbp)
	movl	$0, -24(%rbp)
	movl	-24(%rbp), %eax
	movl	%eax, -28(%rbp)
	jmp	.L9
.L12:
	movl	-24(%rbp), %eax
	leal	1(%rax), %edx
	movl	%edx, -24(%rbp)
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -4(%rbp)
	movl	-4(%rbp), %eax
	cmpl	-8(%rbp), %eax
	jg	.L9
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	f(%rip), %rax
	movl	(%rdx,%rax), %eax
	testl	%eax, %eax
	jne	.L10
	addl	$1, -20(%rbp)
.L10:
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	f(%rip), %rax
	movl	(%rdx,%rax), %eax
	leal	1(%rax), %ecx
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	f(%rip), %rax
	movl	%ecx, (%rdx,%rax)
.L9:
	movl	-20(%rbp), %eax
	cmpl	-8(%rbp), %eax
	jge	.L11
	movl	-24(%rbp), %eax
	cmpl	-12(%rbp), %eax
	jl	.L12
.L11:
	movl	-20(%rbp), %eax
	cmpl	-8(%rbp), %eax
	jge	.L14
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	movl	$0, %eax
	jmp	.L6
.L15:
	addl	$1, -28(%rbp)
	movl	-4(%rbp), %eax
	cmpl	-8(%rbp), %eax
	jg	.L14
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	f(%rip), %rax
	movl	(%rdx,%rax), %eax
	leal	-1(%rax), %ecx
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	f(%rip), %rax
	movl	%ecx, (%rdx,%rax)
.L14:
	movl	-28(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -4(%rbp)
	movl	-4(%rbp), %eax
	cmpl	-8(%rbp), %eax
	jg	.L15
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	f(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	$1, %eax
	jg	.L15
	movl	-24(%rbp), %eax
	subl	-28(%rbp), %eax
	movl	%eax, -16(%rbp)
	jmp	.L16
.L20:
	movl	-24(%rbp), %eax
	leal	1(%rax), %edx
	movl	%edx, -24(%rbp)
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -4(%rbp)
	movl	-4(%rbp), %eax
	cmpl	-8(%rbp), %eax
	jg	.L18
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	f(%rip), %rax
	movl	(%rdx,%rax), %eax
	leal	1(%rax), %ecx
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	f(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	jmp	.L18
.L19:
	addl	$1, -28(%rbp)
	movl	-4(%rbp), %eax
	cmpl	-8(%rbp), %eax
	jg	.L18
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	f(%rip), %rax
	movl	(%rdx,%rax), %eax
	leal	-1(%rax), %ecx
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	f(%rip), %rax
	movl	%ecx, (%rdx,%rax)
.L18:
	movl	-28(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -4(%rbp)
	movl	-4(%rbp), %eax
	cmpl	-8(%rbp), %eax
	jg	.L19
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	f(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	$1, %eax
	jg	.L19
	movl	-24(%rbp), %eax
	subl	-28(%rbp), %eax
	cmpl	%eax, -16(%rbp)
	jle	.L16
	movl	-24(%rbp), %eax
	subl	-28(%rbp), %eax
	movl	%eax, -16(%rbp)
.L16:
	movl	-24(%rbp), %eax
	cmpl	-12(%rbp), %eax
	jl	.L20
	movl	-16(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
.L6:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.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	in
	.type	in, @function
in:
.LFB6:
	.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
	movl	$0, -8(%rbp)
	call	getchar_unlocked@PLT
	movl	%eax, -4(%rbp)
.L2:
	movl	-8(%rbp), %edx
	movl	%edx, %eax
	sall	$2, %eax
	addl	%edx, %eax
	addl	%eax, %eax
	movl	%eax, %edx
	movl	-4(%rbp), %eax
	andl	$15, %eax
	addl	%edx, %eax
	movl	%eax, -8(%rbp)
	call	getchar_unlocked@PLT
	movl	%eax, -4(%rbp)
	cmpl	$47, -4(%rbp)
	jg	.L2
	movl	-8(%rbp), %eax
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	in, .-in
	.globl	a
	.bss
	.align 32
	.type	a, @object
	.size	a, 400012
a:
	.zero	400012
	.globl	f
	.align 32
	.type	f, @object
	.size	f, 400012
f:
	.zero	400012
	.section	.rodata
.LC0:
	.string	"0"
.LC1:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB7:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$32, %rsp
	movl	$0, %eax
	call	in
	movl	%eax, -12(%rbp)
	movl	$0, %eax
	call	in
	movl	%eax, -8(%rbp)
	movl	-12(%rbp), %eax
	cmpl	-8(%rbp), %eax
	jge	.L5
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	movl	$0, %eax
	jmp	.L6
.L5:
	movl	$0, -28(%rbp)
	jmp	.L7
.L8:
	movl	$0, %eax
	call	in
	movl	-28(%rbp), %edx
	movslq	%edx, %rdx
	leaq	0(,%rdx,4), %rcx
	leaq	a(%rip), %rdx
	movl	%eax, (%rcx,%rdx)
	addl	$1, -28(%rbp)
.L7:
	movl	-28(%rbp), %eax
	cmpl	-12(%rbp), %eax
	jl	.L8
	movl	$0, -20(%rbp)
	movl	$0, -24(%rbp)
	movl	-24(%rbp), %eax
	movl	%eax, -28(%rbp)
	jmp	.L9
.L12:
	movl	-24(%rbp), %eax
	leal	1(%rax), %edx
	movl	%edx, -24(%rbp)
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -4(%rbp)
	movl	-4(%rbp), %eax
	cmpl	-8(%rbp), %eax
	jg	.L9
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	f(%rip), %rax
	movl	(%rdx,%rax), %eax
	testl	%eax, %eax
	jne	.L10
	addl	$1, -20(%rbp)
.L10:
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	f(%rip), %rax
	movl	(%rdx,%rax), %eax
	leal	1(%rax), %ecx
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	f(%rip), %rax
	movl	%ecx, (%rdx,%rax)
.L9:
	movl	-20(%rbp), %eax
	cmpl	-8(%rbp), %eax
	jge	.L11
	movl	-24(%rbp), %eax
	cmpl	-12(%rbp), %eax
	jl	.L12
.L11:
	movl	-20(%rbp), %eax
	cmpl	-8(%rbp), %eax
	jge	.L14
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	movl	$0, %eax
	jmp	.L6
.L15:
	addl	$1, -28(%rbp)
	movl	-4(%rbp), %eax
	cmpl	-8(%rbp), %eax
	jg	.L14
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	f(%rip), %rax
	movl	(%rdx,%rax), %eax
	leal	-1(%rax), %ecx
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	f(%rip), %rax
	movl	%ecx, (%rdx,%rax)
.L14:
	movl	-28(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -4(%rbp)
	movl	-4(%rbp), %eax
	cmpl	-8(%rbp), %eax
	jg	.L15
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	f(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	$1, %eax
	jg	.L15
	movl	-24(%rbp), %eax
	subl	-28(%rbp), %eax
	movl	%eax, -16(%rbp)
	jmp	.L16
.L20:
	movl	-24(%rbp), %eax
	leal	1(%rax), %edx
	movl	%edx, -24(%rbp)
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -4(%rbp)
	movl	-4(%rbp), %eax
	cmpl	-8(%rbp), %eax
	jg	.L18
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	f(%rip), %rax
	movl	(%rdx,%rax), %eax
	leal	1(%rax), %ecx
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	f(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	jmp	.L18
.L19:
	addl	$1, -28(%rbp)
	movl	-4(%rbp), %eax
	cmpl	-8(%rbp), %eax
	jg	.L18
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	f(%rip), %rax
	movl	(%rdx,%rax), %eax
	leal	-1(%rax), %ecx
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	f(%rip), %rax
	movl	%ecx, (%rdx,%rax)
.L18:
	movl	-28(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	a(%rip), %rax
	movl	(%rdx,%rax), %eax
	movl	%eax, -4(%rbp)
	movl	-4(%rbp), %eax
	cmpl	-8(%rbp), %eax
	jg	.L19
	movl	-4(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	f(%rip), %rax
	movl	(%rdx,%rax), %eax
	cmpl	$1, %eax
	jg	.L19
	movl	-24(%rbp), %eax
	subl	-28(%rbp), %eax
	cmpl	%eax, -16(%rbp)
	jle	.L16
	movl	-24(%rbp), %eax
	subl	-28(%rbp), %eax
	movl	%eax, -16(%rbp)
.L16:
	movl	-24(%rbp), %eax
	cmpl	-12(%rbp), %eax
	jl	.L20
	movl	-16(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
.L6:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.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:
