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

```c
// AOJ 2894: Binary String with Slit
// 2019.2.24 bal4u

#include <stdio.h>
#include <stdlib.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;
}

int ins(char *s)
{
	char *p = s;
	do *s = gc();
	while (*s++ > ' ');
	*--s = 0;
	return s - p;
}

char s[55] = { '1' }, *S = s + 1;
char t[55] = { '1' }, *T = t + 1;
int main()
{
	int Q, i, j, k, n, ans;

	Q = in();
	while (Q--) {
		n = ins(S), ins(T), T[n] = 1;
		i = 0; while (S[i] == T[i]) i++;
		if (i == n) ans = 0;
		else {
			j = k = n - 1;
			while (S[j] == '0') j--;
			while (T[k] == '0') k--;
			if (j < i) ans = k - j;
			else if (k < i) ans = j - k;
			else if (k == i) ans = j - i;
			else ans = j + k - 2*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	ins
	.type	ins, @function
ins:
.LFB7:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$32, %rsp
	movq	%rdi, -24(%rbp)
	movq	-24(%rbp), %rax
	movq	%rax, -8(%rbp)
.L5:
	call	getchar_unlocked@PLT
	movl	%eax, %edx
	movq	-24(%rbp), %rax
	movb	%dl, (%rax)
	movq	-24(%rbp), %rax
	leaq	1(%rax), %rdx
	movq	%rdx, -24(%rbp)
	movzbl	(%rax), %eax
	cmpb	$32, %al
	jg	.L5
	subq	$1, -24(%rbp)
	movq	-24(%rbp), %rax
	movb	$0, (%rax)
	movq	-24(%rbp), %rax
	subq	-8(%rbp), %rax
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.size	ins, .-ins
	.globl	s
	.data
	.align 32
	.type	s, @object
	.size	s, 55
s:
	.string	"1"
	.zero	53
	.globl	S
	.section	.data.rel.local,"aw"
	.align 8
	.type	S, @object
	.size	S, 8
S:
	.quad	s+1
	.globl	t
	.data
	.align 32
	.type	t, @object
	.size	t, 55
t:
	.string	"1"
	.zero	53
	.globl	T
	.section	.data.rel.local
	.align 8
	.type	T, @object
	.size	T, 8
T:
	.quad	t+1
	.section	.rodata
.LC0:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB8:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$32, %rsp
	movl	$0, %eax
	call	in
	movl	%eax, -24(%rbp)
	jmp	.L8
.L20:
	movq	S(%rip), %rax
	movq	%rax, %rdi
	call	ins
	movl	%eax, -4(%rbp)
	movq	T(%rip), %rax
	movq	%rax, %rdi
	call	ins
	movq	T(%rip), %rdx
	movl	-4(%rbp), %eax
	cltq
	addq	%rdx, %rax
	movb	$1, (%rax)
	movl	$0, -20(%rbp)
	jmp	.L9
.L10:
	addl	$1, -20(%rbp)
.L9:
	movq	S(%rip), %rdx
	movl	-20(%rbp), %eax
	cltq
	addq	%rdx, %rax
	movzbl	(%rax), %edx
	movq	T(%rip), %rcx
	movl	-20(%rbp), %eax
	cltq
	addq	%rcx, %rax
	movzbl	(%rax), %eax
	cmpb	%al, %dl
	je	.L10
	movl	-20(%rbp), %eax
	cmpl	-4(%rbp), %eax
	jne	.L11
	movl	$0, -8(%rbp)
	jmp	.L12
.L11:
	movl	-4(%rbp), %eax
	subl	$1, %eax
	movl	%eax, -12(%rbp)
	movl	-12(%rbp), %eax
	movl	%eax, -16(%rbp)
	jmp	.L13
.L14:
	subl	$1, -16(%rbp)
.L13:
	movq	S(%rip), %rdx
	movl	-16(%rbp), %eax
	cltq
	addq	%rdx, %rax
	movzbl	(%rax), %eax
	cmpb	$48, %al
	je	.L14
	jmp	.L15
.L16:
	subl	$1, -12(%rbp)
.L15:
	movq	T(%rip), %rdx
	movl	-12(%rbp), %eax
	cltq
	addq	%rdx, %rax
	movzbl	(%rax), %eax
	cmpb	$48, %al
	je	.L16
	movl	-16(%rbp), %eax
	cmpl	-20(%rbp), %eax
	jge	.L17
	movl	-12(%rbp), %eax
	subl	-16(%rbp), %eax
	movl	%eax, -8(%rbp)
	jmp	.L12
.L17:
	movl	-12(%rbp), %eax
	cmpl	-20(%rbp), %eax
	jge	.L18
	movl	-16(%rbp), %eax
	subl	-12(%rbp), %eax
	movl	%eax, -8(%rbp)
	jmp	.L12
.L18:
	movl	-12(%rbp), %eax
	cmpl	-20(%rbp), %eax
	jne	.L19
	movl	-16(%rbp), %eax
	subl	-20(%rbp), %eax
	movl	%eax, -8(%rbp)
	jmp	.L12
.L19:
	movl	-16(%rbp), %edx
	movl	-12(%rbp), %eax
	addl	%eax, %edx
	movl	-20(%rbp), %eax
	leal	(%rax,%rax), %ecx
	movl	%edx, %eax
	subl	%ecx, %eax
	movl	%eax, -8(%rbp)
.L12:
	movl	-8(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L8:
	movl	-24(%rbp), %eax
	leal	-1(%rax), %edx
	movl	%edx, -24(%rbp)
	testl	%eax, %eax
	jne	.L20
	movl	$0, %eax
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE8:
	.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:
.LFB39:
	.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
.LFE39:
	.size	in, .-in
	.p2align 4
	.globl	ins
	.type	ins, @function
ins:
.LFB40:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rdi, %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 24
	.cfi_offset 3, -24
	movq	%rdi, %rbx
	subq	$8, %rsp
	.cfi_def_cfa_offset 32
	jmp	.L16
	.p2align 4,,10
	.p2align 3
.L13:
	leaq	1(%rax), %rdx
	movq	%rdx, 8(%rdi)
	movzbl	(%rax), %eax
	leaq	1(%rbx), %rdx
	movb	%al, (%rbx)
	cmpb	$32, %al
	jle	.L15
.L14:
	movq	%rdx, %rbx
.L16:
	movq	stdin(%rip), %rdi
	movq	8(%rdi), %rax
	cmpq	16(%rdi), %rax
	jb	.L13
	call	__uflow@PLT
	leaq	1(%rbx), %rdx
	movb	%al, (%rbx)
	cmpb	$32, %al
	jg	.L14
.L15:
	movb	$0, -1(%rdx)
	movl	%ebx, %eax
	addq	$8, %rsp
	.cfi_def_cfa_offset 24
	subl	%ebp, %eax
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE40:
	.size	ins, .-ins
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB41:
	.cfi_startproc
	endbr64
	pushq	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	xorl	%eax, %eax
	pushq	%r13
	.cfi_def_cfa_offset 24
	.cfi_offset 13, -24
	pushq	%r12
	.cfi_def_cfa_offset 32
	.cfi_offset 12, -32
	pushq	%rbp
	.cfi_def_cfa_offset 40
	.cfi_offset 6, -40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	call	in
	testl	%eax, %eax
	je	.L19
	movl	%eax, %ebx
	leaq	.LC0(%rip), %rbp
	.p2align 4,,10
	.p2align 3
.L38:
	movq	S(%rip), %r14
	movq	%r14, %r13
	jmp	.L23
	.p2align 4,,10
	.p2align 3
.L20:
	leaq	1(%rax), %rdx
	movq	%rdx, 8(%rdi)
	movzbl	(%rax), %eax
	leaq	1(%r13), %rdx
	movb	%al, 0(%r13)
	cmpb	$32, %al
	jle	.L22
.L21:
	movq	%rdx, %r13
.L23:
	movq	stdin(%rip), %rdi
	movq	8(%rdi), %rax
	cmpq	16(%rdi), %rax
	jb	.L20
	call	__uflow@PLT
	leaq	1(%r13), %rdx
	movb	%al, 0(%r13)
	cmpb	$32, %al
	jg	.L21
	.p2align 4,,10
	.p2align 3
.L22:
	movb	$0, -1(%rdx)
	subq	%r14, %r13
	movq	T(%rip), %r12
	jmp	.L27
	.p2align 4,,10
	.p2align 3
.L24:
	leaq	1(%rax), %rdx
	addq	$1, %r12
	movq	%rdx, 8(%rdi)
	movzbl	(%rax), %eax
	movb	%al, -1(%r12)
	cmpb	$32, %al
	jle	.L26
.L27:
	movq	stdin(%rip), %rdi
	movq	8(%rdi), %rax
	cmpq	16(%rdi), %rax
	jb	.L24
	call	__uflow@PLT
	addq	$1, %r12
	movb	%al, -1(%r12)
	cmpb	$32, %al
	jg	.L27
	.p2align 4,,10
	.p2align 3
.L26:
	movb	$0, -1(%r12)
	movq	T(%rip), %rdx
	movslq	%r13d, %rax
	movb	$1, (%rdx,%rax)
	movq	S(%rip), %rsi
	movq	T(%rip), %rcx
	movzbl	(%rsi), %eax
	cmpb	%al, (%rcx)
	jne	.L39
	movl	$1, %eax
	.p2align 4,,10
	.p2align 3
.L29:
	movzbl	(%rsi,%rax), %edx
	movl	%eax, %edi
	addq	$1, %rax
	cmpb	-1(%rcx,%rax), %dl
	je	.L29
.L28:
	xorl	%r9d, %r9d
	cmpl	%r13d, %edi
	jne	.L50
.L30:
	xorl	%eax, %eax
	movl	%r9d, %edx
	movq	%rbp, %rsi
	movl	$1, %edi
	call	__printf_chk@PLT
	subl	$1, %ebx
	jne	.L38
.L19:
	popq	%rbx
	.cfi_remember_state
	.cfi_def_cfa_offset 40
	xorl	%eax, %eax
	popq	%rbp
	.cfi_def_cfa_offset 32
	popq	%r12
	.cfi_def_cfa_offset 24
	popq	%r13
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L50:
	.cfi_restore_state
	leal	-1(%r13), %edx
	movslq	%edx, %r9
	cmpb	$48, (%rsi,%r9)
	jne	.L41
	leal	-2(%r13), %eax
	cltq
	.p2align 4,,10
	.p2align 3
.L32:
	movl	%eax, %r8d
	subq	$1, %rax
	cmpb	$48, 1(%rsi,%rax)
	je	.L32
.L31:
	cmpb	$48, (%rcx,%r9)
	jne	.L33
	leal	-2(%r13), %eax
	cltq
	.p2align 4,,10
	.p2align 3
.L34:
	movl	%eax, %edx
	subq	$1, %rax
	cmpb	$48, 1(%rcx,%rax)
	je	.L34
.L33:
	cmpl	%r8d, %edi
	jle	.L35
	subl	%r8d, %edx
	movl	%edx, %r9d
	jmp	.L30
	.p2align 4,,10
	.p2align 3
.L35:
	cmpl	%edx, %edi
	jle	.L36
	movl	%r8d, %r9d
	subl	%edx, %r9d
	jmp	.L30
	.p2align 4,,10
	.p2align 3
.L39:
	xorl	%edi, %edi
	jmp	.L28
	.p2align 4,,10
	.p2align 3
.L36:
	je	.L51
	leal	(%rdx,%r8), %r9d
	addl	%edi, %edi
	subl	%edi, %r9d
	jmp	.L30
.L41:
	movl	%edx, %r8d
	jmp	.L31
.L51:
	movl	%r8d, %r9d
	subl	%edi, %r9d
	jmp	.L30
	.cfi_endproc
.LFE41:
	.size	main, .-main
	.globl	T
	.section	.data.rel.local,"aw"
	.align 8
	.type	T, @object
	.size	T, 8
T:
	.quad	t+1
	.globl	t
	.data
	.align 32
	.type	t, @object
	.size	t, 55
t:
	.string	"1"
	.zero	53
	.globl	S
	.section	.data.rel.local
	.align 8
	.type	S, @object
	.size	S, 8
S:
	.quad	s+1
	.globl	s
	.data
	.align 32
	.type	s, @object
	.size	s, 55
s:
	.string	"1"
	.zero	53
	.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:
.LFB39:
	.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
.LFE39:
	.size	in, .-in
	.p2align 4
	.globl	ins
	.type	ins, @function
ins:
.LFB40:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rdi, %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 24
	.cfi_offset 3, -24
	movq	%rdi, %rbx
	subq	$8, %rsp
	.cfi_def_cfa_offset 32
	jmp	.L16
	.p2align 4,,10
	.p2align 3
.L13:
	leaq	1(%rax), %rdx
	movq	%rdx, 8(%rdi)
	movzbl	(%rax), %eax
	leaq	1(%rbx), %rdx
	movb	%al, (%rbx)
	cmpb	$32, %al
	jle	.L15
.L14:
	movq	%rdx, %rbx
.L16:
	movq	stdin(%rip), %rdi
	movq	8(%rdi), %rax
	cmpq	16(%rdi), %rax
	jb	.L13
	call	__uflow@PLT
	leaq	1(%rbx), %rdx
	movb	%al, (%rbx)
	cmpb	$32, %al
	jg	.L14
.L15:
	movb	$0, -1(%rdx)
	movl	%ebx, %eax
	addq	$8, %rsp
	.cfi_def_cfa_offset 24
	subl	%ebp, %eax
	popq	%rbx
	.cfi_def_cfa_offset 16
	popq	%rbp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE40:
	.size	ins, .-ins
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB41:
	.cfi_startproc
	endbr64
	pushq	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	xorl	%eax, %eax
	pushq	%r13
	.cfi_def_cfa_offset 24
	.cfi_offset 13, -24
	pushq	%r12
	.cfi_def_cfa_offset 32
	.cfi_offset 12, -32
	pushq	%rbp
	.cfi_def_cfa_offset 40
	.cfi_offset 6, -40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	call	in
	testl	%eax, %eax
	je	.L19
	movl	%eax, %ebx
	leaq	.LC0(%rip), %rbp
	.p2align 4,,10
	.p2align 3
.L38:
	movq	S(%rip), %r14
	movq	%r14, %r13
	jmp	.L23
	.p2align 4,,10
	.p2align 3
.L20:
	leaq	1(%rax), %rdx
	movq	%rdx, 8(%rdi)
	movzbl	(%rax), %eax
	leaq	1(%r13), %rdx
	movb	%al, 0(%r13)
	cmpb	$32, %al
	jle	.L22
.L21:
	movq	%rdx, %r13
.L23:
	movq	stdin(%rip), %rdi
	movq	8(%rdi), %rax
	cmpq	16(%rdi), %rax
	jb	.L20
	call	__uflow@PLT
	leaq	1(%r13), %rdx
	movb	%al, 0(%r13)
	cmpb	$32, %al
	jg	.L21
	.p2align 4,,10
	.p2align 3
.L22:
	movb	$0, -1(%rdx)
	subq	%r14, %r13
	movq	T(%rip), %r12
	jmp	.L27
	.p2align 4,,10
	.p2align 3
.L24:
	leaq	1(%rax), %rdx
	addq	$1, %r12
	movq	%rdx, 8(%rdi)
	movzbl	(%rax), %eax
	movb	%al, -1(%r12)
	cmpb	$32, %al
	jle	.L26
.L27:
	movq	stdin(%rip), %rdi
	movq	8(%rdi), %rax
	cmpq	16(%rdi), %rax
	jb	.L24
	call	__uflow@PLT
	addq	$1, %r12
	movb	%al, -1(%r12)
	cmpb	$32, %al
	jg	.L27
	.p2align 4,,10
	.p2align 3
.L26:
	movb	$0, -1(%r12)
	movq	T(%rip), %rdx
	movslq	%r13d, %rax
	movb	$1, (%rdx,%rax)
	movq	S(%rip), %rsi
	movq	T(%rip), %rcx
	movzbl	(%rsi), %eax
	cmpb	%al, (%rcx)
	jne	.L39
	movl	$1, %eax
	.p2align 4,,10
	.p2align 3
.L29:
	movzbl	(%rsi,%rax), %edx
	movl	%eax, %edi
	addq	$1, %rax
	cmpb	-1(%rcx,%rax), %dl
	je	.L29
.L28:
	xorl	%r9d, %r9d
	cmpl	%r13d, %edi
	jne	.L50
.L30:
	xorl	%eax, %eax
	movl	%r9d, %edx
	movq	%rbp, %rsi
	movl	$1, %edi
	call	__printf_chk@PLT
	subl	$1, %ebx
	jne	.L38
.L19:
	popq	%rbx
	.cfi_remember_state
	.cfi_def_cfa_offset 40
	xorl	%eax, %eax
	popq	%rbp
	.cfi_def_cfa_offset 32
	popq	%r12
	.cfi_def_cfa_offset 24
	popq	%r13
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L50:
	.cfi_restore_state
	leal	-1(%r13), %edx
	movslq	%edx, %r9
	cmpb	$48, (%rsi,%r9)
	jne	.L41
	leal	-2(%r13), %eax
	cltq
	.p2align 4,,10
	.p2align 3
.L32:
	movl	%eax, %r8d
	subq	$1, %rax
	cmpb	$48, 1(%rsi,%rax)
	je	.L32
.L31:
	cmpb	$48, (%rcx,%r9)
	jne	.L33
	leal	-2(%r13), %eax
	cltq
	.p2align 4,,10
	.p2align 3
.L34:
	movl	%eax, %edx
	subq	$1, %rax
	cmpb	$48, 1(%rcx,%rax)
	je	.L34
.L33:
	cmpl	%r8d, %edi
	jle	.L35
	subl	%r8d, %edx
	movl	%edx, %r9d
	jmp	.L30
	.p2align 4,,10
	.p2align 3
.L35:
	cmpl	%edx, %edi
	jle	.L36
	movl	%r8d, %r9d
	subl	%edx, %r9d
	jmp	.L30
	.p2align 4,,10
	.p2align 3
.L39:
	xorl	%edi, %edi
	jmp	.L28
	.p2align 4,,10
	.p2align 3
.L36:
	je	.L51
	leal	(%rdx,%r8), %r9d
	addl	%edi, %edi
	subl	%edi, %r9d
	jmp	.L30
.L41:
	movl	%edx, %r8d
	jmp	.L31
.L51:
	movl	%r8d, %r9d
	subl	%edi, %r9d
	jmp	.L30
	.cfi_endproc
.LFE41:
	.size	main, .-main
	.globl	T
	.section	.data.rel.local,"aw"
	.align 8
	.type	T, @object
	.size	T, 8
T:
	.quad	t+1
	.globl	t
	.data
	.align 32
	.type	t, @object
	.size	t, 55
t:
	.string	"1"
	.zero	53
	.globl	S
	.section	.data.rel.local
	.align 8
	.type	S, @object
	.size	S, 8
S:
	.quad	s+1
	.globl	s
	.data
	.align 32
	.type	s, @object
	.size	s, 55
s:
	.string	"1"
	.zero	53
	.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 2894: Binary String with Slit
// 2019.2.24 bal4u

#include <stdio.h>
#include <stdlib.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;
}

int ins(char *s)
{
	char *p = s;
	do *s = gc();
	while (*s++ > ' ');
	*--s = 0;
	return s - p;
}

char s[55] = { '1' }, *S = s + 1;
char t[55] = { '1' }, *T = t + 1;
int main()
{
	int Q, i, j, k, n, ans;

	Q = in();
	while (Q--) {
		n = ins(S), ins(T), T[n] = 1;
		i = 0; while (S[i] == T[i]) i++;
		if (i == n) ans = 0;
		else {
			j = k = n - 1;
			while (S[j] == '0') j--;
			while (T[k] == '0') k--;
			if (j < i) ans = k - j;
			else if (k < i) ans = j - k;
			else if (k == i) ans = j - i;
			else ans = j + k - 2*i;
		}
		printf("%d\n", ans);
	}
	return 0;
}


4
101 100
101 101
1010 1101
11011001 10010101
 4
101 100
101 101
1010 1101
01011001 10010101
 4
101 100
101 111
1010 1101
01011001 10010101
 4
101 110
101 101
0010 1101
11011001 10010101
 4
101 100
101 101
1010 1100
11011001 10010101
 4
101 100
101 011
1010 1101
01011001 10010101
 4
101 110
101 101
0010 1100
11011001 10010101
 4
100 100
101 011
1010 1101
01011001 10010101
 4
101 110
101 101
0010 1100
10011001 10010101
 4
110 100
101 101
1010 1100
11011001 10010101

2
0
3
12
 2
0
3
14
 2
2
3
14
 1
0
5
12
 2
0
1
12
 2
4
3
14
 1
0
3
12
 0
4
3
14
 1
0
3
6
 1
0
1
12

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

```c
// AOJ 2894: Binary String with Slit
// 2019.2.24 bal4u

#include <stdio.h>
#include <stdlib.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;
}

int ins(char *s)
{
	char *p = s;
	do *s = gc();
	while (*s++ > ' ');
	*--s = 0;
	return s - p;
}

char s[55] = { '1' }, *S = s + 1;
char t[55] = { '1' }, *T = t + 1;
int main()
{
	int Q, i, j, k, n, ans;

	Q = in();
	while (Q--) {
		n = ins(S), ins(T), T[n] = 1;
		i = 0; while (S[i] == T[i]) i++;
		if (i == n) ans = 0;
		else {
			j = k = n - 1;
			while (S[j] == '0') j--;
			while (T[k] == '0') k--;
			if (j < i) ans = k - j;
			else if (k < i) ans = j - k;
			else if (k == i) ans = j - i;
			else ans = j + k - 2*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	ins
	.type	ins, @function
ins:
.LFB7:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$32, %rsp
	movq	%rdi, -24(%rbp)
	movq	-24(%rbp), %rax
	movq	%rax, -8(%rbp)
.L5:
	call	getchar_unlocked@PLT
	movl	%eax, %edx
	movq	-24(%rbp), %rax
	movb	%dl, (%rax)
	movq	-24(%rbp), %rax
	leaq	1(%rax), %rdx
	movq	%rdx, -24(%rbp)
	movzbl	(%rax), %eax
	cmpb	$32, %al
	jg	.L5
	subq	$1, -24(%rbp)
	movq	-24(%rbp), %rax
	movb	$0, (%rax)
	movq	-24(%rbp), %rax
	subq	-8(%rbp), %rax
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.size	ins, .-ins
	.globl	s
	.data
	.align 32
	.type	s, @object
	.size	s, 55
s:
	.string	"1"
	.zero	53
	.globl	S
	.section	.data.rel.local,"aw"
	.align 8
	.type	S, @object
	.size	S, 8
S:
	.quad	s+1
	.globl	t
	.data
	.align 32
	.type	t, @object
	.size	t, 55
t:
	.string	"1"
	.zero	53
	.globl	T
	.section	.data.rel.local
	.align 8
	.type	T, @object
	.size	T, 8
T:
	.quad	t+1
	.section	.rodata
.LC0:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB8:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$32, %rsp
	movl	$0, %eax
	call	in
	movl	%eax, -24(%rbp)
	jmp	.L8
.L20:
	movq	S(%rip), %rax
	movq	%rax, %rdi
	call	ins
	movl	%eax, -4(%rbp)
	movq	T(%rip), %rax
	movq	%rax, %rdi
	call	ins
	movq	T(%rip), %rdx
	movl	-4(%rbp), %eax
	cltq
	addq	%rdx, %rax
	movb	$1, (%rax)
	movl	$0, -20(%rbp)
	jmp	.L9
.L10:
	addl	$1, -20(%rbp)
.L9:
	movq	S(%rip), %rdx
	movl	-20(%rbp), %eax
	cltq
	addq	%rdx, %rax
	movzbl	(%rax), %edx
	movq	T(%rip), %rcx
	movl	-20(%rbp), %eax
	cltq
	addq	%rcx, %rax
	movzbl	(%rax), %eax
	cmpb	%al, %dl
	je	.L10
	movl	-20(%rbp), %eax
	cmpl	-4(%rbp), %eax
	jne	.L11
	movl	$0, -8(%rbp)
	jmp	.L12
.L11:
	movl	-4(%rbp), %eax
	subl	$1, %eax
	movl	%eax, -12(%rbp)
	movl	-12(%rbp), %eax
	movl	%eax, -16(%rbp)
	jmp	.L13
.L14:
	subl	$1, -16(%rbp)
.L13:
	movq	S(%rip), %rdx
	movl	-16(%rbp), %eax
	cltq
	addq	%rdx, %rax
	movzbl	(%rax), %eax
	cmpb	$48, %al
	je	.L14
	jmp	.L15
.L16:
	subl	$1, -12(%rbp)
.L15:
	movq	T(%rip), %rdx
	movl	-12(%rbp), %eax
	cltq
	addq	%rdx, %rax
	movzbl	(%rax), %eax
	cmpb	$48, %al
	je	.L16
	movl	-16(%rbp), %eax
	cmpl	-20(%rbp), %eax
	jge	.L17
	movl	-12(%rbp), %eax
	subl	-16(%rbp), %eax
	movl	%eax, -8(%rbp)
	jmp	.L12
.L17:
	movl	-12(%rbp), %eax
	cmpl	-20(%rbp), %eax
	jge	.L18
	movl	-16(%rbp), %eax
	subl	-12(%rbp), %eax
	movl	%eax, -8(%rbp)
	jmp	.L12
.L18:
	movl	-12(%rbp), %eax
	cmpl	-20(%rbp), %eax
	jne	.L19
	movl	-16(%rbp), %eax
	subl	-20(%rbp), %eax
	movl	%eax, -8(%rbp)
	jmp	.L12
.L19:
	movl	-16(%rbp), %edx
	movl	-12(%rbp), %eax
	addl	%eax, %edx
	movl	-20(%rbp), %eax
	leal	(%rax,%rax), %ecx
	movl	%edx, %eax
	subl	%ecx, %eax
	movl	%eax, -8(%rbp)
.L12:
	movl	-8(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L8:
	movl	-24(%rbp), %eax
	leal	-1(%rax), %edx
	movl	%edx, -24(%rbp)
	testl	%eax, %eax
	jne	.L20
	movl	$0, %eax
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE8:
	.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	ins
	.type	ins, @function
ins:
.LFB7:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$32, %rsp
	movq	%rdi, -24(%rbp)
	movq	-24(%rbp), %rax
	movq	%rax, -8(%rbp)
.L5:
	call	getchar_unlocked@PLT
	movl	%eax, %edx
	movq	-24(%rbp), %rax
	movb	%dl, (%rax)
	movq	-24(%rbp), %rax
	leaq	1(%rax), %rdx
	movq	%rdx, -24(%rbp)
	movzbl	(%rax), %eax
	cmpb	$32, %al
	jg	.L5
	subq	$1, -24(%rbp)
	movq	-24(%rbp), %rax
	movb	$0, (%rax)
	movq	-24(%rbp), %rax
	subq	-8(%rbp), %rax
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.size	ins, .-ins
	.globl	s
	.data
	.align 32
	.type	s, @object
	.size	s, 55
s:
	.string	"1"
	.zero	53
	.globl	S
	.section	.data.rel.local,"aw"
	.align 8
	.type	S, @object
	.size	S, 8
S:
	.quad	s+1
	.globl	t
	.data
	.align 32
	.type	t, @object
	.size	t, 55
t:
	.string	"1"
	.zero	53
	.globl	T
	.section	.data.rel.local
	.align 8
	.type	T, @object
	.size	T, 8
T:
	.quad	t+1
	.section	.rodata
.LC0:
	.string	"%d\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB8:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$32, %rsp
	movl	$0, %eax
	call	in
	movl	%eax, -24(%rbp)
	jmp	.L8
.L20:
	movq	S(%rip), %rax
	movq	%rax, %rdi
	call	ins
	movl	%eax, -4(%rbp)
	movq	T(%rip), %rax
	movq	%rax, %rdi
	call	ins
	movq	T(%rip), %rdx
	movl	-4(%rbp), %eax
	cltq
	addq	%rdx, %rax
	movb	$1, (%rax)
	movl	$0, -20(%rbp)
	jmp	.L9
.L10:
	addl	$1, -20(%rbp)
.L9:
	movq	S(%rip), %rdx
	movl	-20(%rbp), %eax
	cltq
	addq	%rdx, %rax
	movzbl	(%rax), %edx
	movq	T(%rip), %rcx
	movl	-20(%rbp), %eax
	cltq
	addq	%rcx, %rax
	movzbl	(%rax), %eax
	cmpb	%al, %dl
	je	.L10
	movl	-20(%rbp), %eax
	cmpl	-4(%rbp), %eax
	jne	.L11
	movl	$0, -8(%rbp)
	jmp	.L12
.L11:
	movl	-4(%rbp), %eax
	subl	$1, %eax
	movl	%eax, -12(%rbp)
	movl	-12(%rbp), %eax
	movl	%eax, -16(%rbp)
	jmp	.L13
.L14:
	subl	$1, -16(%rbp)
.L13:
	movq	S(%rip), %rdx
	movl	-16(%rbp), %eax
	cltq
	addq	%rdx, %rax
	movzbl	(%rax), %eax
	cmpb	$48, %al
	je	.L14
	jmp	.L15
.L16:
	subl	$1, -12(%rbp)
.L15:
	movq	T(%rip), %rdx
	movl	-12(%rbp), %eax
	cltq
	addq	%rdx, %rax
	movzbl	(%rax), %eax
	cmpb	$48, %al
	je	.L16
	movl	-16(%rbp), %eax
	cmpl	-20(%rbp), %eax
	jge	.L17
	movl	-12(%rbp), %eax
	subl	-16(%rbp), %eax
	movl	%eax, -8(%rbp)
	jmp	.L12
.L17:
	movl	-12(%rbp), %eax
	cmpl	-20(%rbp), %eax
	jge	.L18
	movl	-16(%rbp), %eax
	subl	-12(%rbp), %eax
	movl	%eax, -8(%rbp)
	jmp	.L12
.L18:
	movl	-12(%rbp), %eax
	cmpl	-20(%rbp), %eax
	jne	.L19
	movl	-16(%rbp), %eax
	subl	-20(%rbp), %eax
	movl	%eax, -8(%rbp)
	jmp	.L12
.L19:
	movl	-16(%rbp), %edx
	movl	-12(%rbp), %eax
	addl	%eax, %edx
	movl	-20(%rbp), %eax
	leal	(%rax,%rax), %ecx
	movl	%edx, %eax
	subl	%ecx, %eax
	movl	%eax, -8(%rbp)
.L12:
	movl	-8(%rbp), %eax
	movl	%eax, %esi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L8:
	movl	-24(%rbp), %eax
	leal	-1(%rax), %edx
	movl	%edx, -24(%rbp)
	testl	%eax, %eax
	jne	.L20
	movl	$0, %eax
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE8:
	.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:
