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

```c
sz;
k;
char x[18],buf[2200000];
A,B,p,T;
long ans;
main()
{
	sz=read(0,buf,2200000);
	sz-=2;
	while(1)
	{
		A=B=0;
		p=1;
		while(1)
		{
			k=buf[sz--];
			if(k<'0')break;
			B+=(k-'0')*p;
			p*=10;
		}
		p=1;
		if(sz<0)break;
		while(1)
		{
			k=buf[sz--];
			if(k<'0')break;
			A+=(k-'0')*p;
			p*=10;
		}
		T=(-A-ans)%B;
		ans+=T+(T<0)*B;
	}
	sz=17;
	do
	{
		x[--sz]=ans%10+'0';
		ans/=10;
	}while(ans);
	write(1,x+sz,17-sz);
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	sz
	.bss
	.align 4
	.type	sz, @object
	.size	sz, 4
sz:
	.zero	4
	.globl	k
	.align 4
	.type	k, @object
	.size	k, 4
k:
	.zero	4
	.globl	x
	.align 16
	.type	x, @object
	.size	x, 18
x:
	.zero	18
	.globl	buf
	.align 32
	.type	buf, @object
	.size	buf, 2200000
buf:
	.zero	2200000
	.globl	A
	.align 4
	.type	A, @object
	.size	A, 4
A:
	.zero	4
	.globl	B
	.align 4
	.type	B, @object
	.size	B, 4
B:
	.zero	4
	.globl	p
	.align 4
	.type	p, @object
	.size	p, 4
p:
	.zero	4
	.globl	T
	.align 4
	.type	T, @object
	.size	T, 4
T:
	.zero	4
	.globl	ans
	.align 8
	.type	ans, @object
	.size	ans, 8
ans:
	.zero	8
	.text
	.globl	main
	.type	main, @function
main:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	$2200000, %edx
	leaq	buf(%rip), %rax
	movq	%rax, %rsi
	movl	$0, %edi
	movl	$0, %eax
	call	read@PLT
	movl	%eax, sz(%rip)
	movl	sz(%rip), %eax
	subl	$2, %eax
	movl	%eax, sz(%rip)
.L9:
	movl	$0, B(%rip)
	movl	B(%rip), %eax
	movl	%eax, A(%rip)
	movl	$1, p(%rip)
.L4:
	movl	sz(%rip), %eax
	leal	-1(%rax), %edx
	movl	%edx, sz(%rip)
	cltq
	leaq	buf(%rip), %rdx
	movzbl	(%rax,%rdx), %eax
	movsbl	%al, %eax
	movl	%eax, k(%rip)
	movl	k(%rip), %eax
	cmpl	$47, %eax
	jle	.L15
	movl	k(%rip), %eax
	leal	-48(%rax), %edx
	movl	p(%rip), %eax
	imull	%eax, %edx
	movl	B(%rip), %eax
	addl	%edx, %eax
	movl	%eax, B(%rip)
	movl	p(%rip), %edx
	movl	%edx, %eax
	sall	$2, %eax
	addl	%edx, %eax
	addl	%eax, %eax
	movl	%eax, p(%rip)
	jmp	.L4
.L15:
	nop
	movl	$1, p(%rip)
	movl	sz(%rip), %eax
	testl	%eax, %eax
	js	.L16
.L5:
	movl	sz(%rip), %eax
	leal	-1(%rax), %edx
	movl	%edx, sz(%rip)
	cltq
	leaq	buf(%rip), %rdx
	movzbl	(%rax,%rdx), %eax
	movsbl	%al, %eax
	movl	%eax, k(%rip)
	movl	k(%rip), %eax
	cmpl	$47, %eax
	jle	.L17
	movl	k(%rip), %eax
	leal	-48(%rax), %edx
	movl	p(%rip), %eax
	imull	%eax, %edx
	movl	A(%rip), %eax
	addl	%edx, %eax
	movl	%eax, A(%rip)
	movl	p(%rip), %edx
	movl	%edx, %eax
	sall	$2, %eax
	addl	%edx, %eax
	addl	%eax, %eax
	movl	%eax, p(%rip)
	jmp	.L5
.L17:
	nop
	movl	A(%rip), %eax
	negl	%eax
	cltq
	movq	ans(%rip), %rdx
	subq	%rdx, %rax
	movl	B(%rip), %edx
	movslq	%edx, %rcx
	cqto
	idivq	%rcx
	movq	%rdx, %rax
	movl	%eax, T(%rip)
	movl	T(%rip), %eax
	shrl	$31, %eax
	movzbl	%al, %edx
	movl	B(%rip), %eax
	imull	%eax, %edx
	movl	T(%rip), %eax
	addl	%edx, %eax
	movslq	%eax, %rdx
	movq	ans(%rip), %rax
	addq	%rdx, %rax
	movq	%rax, ans(%rip)
	jmp	.L9
.L16:
	nop
	movl	$17, sz(%rip)
.L10:
	movq	ans(%rip), %rcx
	movabsq	$7378697629483820647, %rdx
	movq	%rcx, %rax
	imulq	%rdx
	movq	%rdx, %rax
	sarq	$2, %rax
	movq	%rcx, %rsi
	sarq	$63, %rsi
	subq	%rsi, %rax
	movq	%rax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rax, %rax
	subq	%rax, %rcx
	movq	%rcx, %rdx
	movl	%edx, %eax
	leal	48(%rax), %edx
	movl	sz(%rip), %eax
	subl	$1, %eax
	movl	%eax, sz(%rip)
	movl	sz(%rip), %eax
	movl	%edx, %ecx
	cltq
	leaq	x(%rip), %rdx
	movb	%cl, (%rax,%rdx)
	movq	ans(%rip), %rcx
	movabsq	$7378697629483820647, %rdx
	movq	%rcx, %rax
	imulq	%rdx
	movq	%rdx, %rax
	sarq	$2, %rax
	sarq	$63, %rcx
	movq	%rcx, %rdx
	subq	%rdx, %rax
	movq	%rax, ans(%rip)
	movq	ans(%rip), %rax
	testq	%rax, %rax
	jne	.L10
	movl	sz(%rip), %eax
	movl	$17, %edx
	subl	%eax, %edx
	movl	sz(%rip), %eax
	cltq
	leaq	x(%rip), %rcx
	addq	%rcx, %rax
	movq	%rax, %rsi
	movl	$1, %edi
	movl	$0, %eax
	call	write@PLT
	movl	$0, %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	main, .-main
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:
```

Only output the optimized assembly code. Do not include any other text. Do not write any comments in the assembly code. Wrap the assembly code in ```assembly``` tags.
user
	.file	"temp.c"
	.text
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	xorl	%edi, %edi
	movl	$2200000, %edx
	xorl	%eax, %eax
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	xorl	%r12d, %r12d
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	leaq	buf(%rip), %rbx
	movq	%rbx, %rsi
	call	read@PLT
	movq	ans(%rip), %r8
	leaq	1(%rbx), %rsi
	xorl	%r9d, %r9d
	leal	-2(%rax), %r10d
	movslq	%r10d, %rax
	movq	%r8, %rdi
	leal	-1(%r10), %r11d
	movsbl	(%rbx,%rax), %eax
	cmpl	$47, %eax
	jle	.L10
	.p2align 4,,10
	.p2align 3
.L35:
	subl	$2, %r10d
	xorl	%ecx, %ecx
	movl	$1, %edx
	movslq	%r10d, %r10
	.p2align 4,,10
	.p2align 3
.L3:
	subl	$48, %eax
	movl	%r10d, %r11d
	imull	%edx, %eax
	leal	(%rdx,%rdx,4), %edx
	addl	%edx, %edx
	addl	%eax, %ecx
	movsbl	(%rsi,%r10), %eax
	subq	$1, %r10
	cmpl	$47, %eax
	jg	.L3
	testl	%r11d, %r11d
	js	.L4
.L36:
	movslq	%r11d, %rax
	leal	-1(%r11), %r10d
	movsbl	(%rbx,%rax), %edx
	cmpl	$47, %edx
	jle	.L11
	leal	-2(%r11), %ebp
	xorl	%eax, %eax
	movl	$1, %r11d
	movslq	%ebp, %rbp
	.p2align 4,,10
	.p2align 3
.L6:
	subl	$48, %edx
	movl	%ebp, %r10d
	imull	%r11d, %edx
	leal	(%r11,%r11,4), %r11d
	addl	%r11d, %r11d
	addl	%edx, %eax
	movsbl	(%rsi,%rbp), %edx
	subq	$1, %rbp
	cmpl	$47, %edx
	jg	.L6
	negl	%eax
	cltq
.L5:
	subq	%rdi, %rax
	movslq	%ecx, %r11
	movl	$1, %r12d
	cqto
	idivq	%r11
	movslq	%r10d, %rax
	leal	-1(%r10), %r11d
	movsbl	(%rbx,%rax), %eax
	testl	%edx, %edx
	movl	%edx, %ebp
	cmovns	%r9d, %ecx
	addl	%edx, %ecx
	movslq	%ecx, %rcx
	addq	%rcx, %rdi
	cmpl	$47, %eax
	jg	.L35
.L10:
	xorl	%ecx, %ecx
	testl	%r11d, %r11d
	jns	.L36
	.p2align 4,,10
	.p2align 3
.L4:
	movl	%eax, k(%rip)
	movl	$1, p(%rip)
	movl	%ecx, B(%rip)
	movl	$0, A(%rip)
	testb	%r12b, %r12b
	je	.L8
	movl	%ebp, T(%rip)
	movq	%rdi, %r8
.L8:
	movabsq	$7378697629483820647, %rsi
	movq	%r8, %rax
	imulq	%rsi
	movq	%r8, %rax
	sarq	$63, %rax
	movq	%rdx, %rcx
	sarq	$2, %rcx
	subq	%rax, %rcx
	leaq	(%rcx,%rcx,4), %rax
	addq	%rax, %rax
	subq	%rax, %r8
	leal	48(%r8), %eax
	movb	%al, 16+x(%rip)
	testq	%rcx, %rcx
	je	.L12
	movq	%rcx, %rax
	imulq	%rsi
	movq	%rcx, %rax
	sarq	$63, %rax
	sarq	$2, %rdx
	subq	%rax, %rdx
	leaq	(%rdx,%rdx,4), %rax
	addq	%rax, %rax
	subq	%rax, %rcx
	leal	48(%rcx), %eax
	movq	%rdx, %rcx
	movb	%al, 15+x(%rip)
	testq	%rdx, %rdx
	je	.L13
	movq	%rdx, %rax
	imulq	%rsi
	movq	%rcx, %rax
	sarq	$63, %rax
	sarq	$2, %rdx
	subq	%rax, %rdx
	leaq	(%rdx,%rdx,4), %rax
	addq	%rax, %rax
	subq	%rax, %rcx
	leal	48(%rcx), %eax
	movq	%rdx, %rcx
	movb	%al, 14+x(%rip)
	testq	%rdx, %rdx
	je	.L14
	movq	%rdx, %rax
	imulq	%rsi
	movq	%rcx, %rax
	sarq	$63, %rax
	sarq	$2, %rdx
	subq	%rax, %rdx
	leaq	(%rdx,%rdx,4), %rax
	addq	%rax, %rax
	subq	%rax, %rcx
	leal	48(%rcx), %eax
	movq	%rdx, %rcx
	movb	%al, 13+x(%rip)
	testq	%rdx, %rdx
	je	.L15
	movq	%rdx, %rax
	movl	$10, %esi
	cqto
	idivq	%rsi
	addl	$48, %edx
	movq	%rax, %rcx
	movb	%dl, 12+x(%rip)
	testq	%rax, %rax
	je	.L16
	cqto
	idivq	%rsi
	addl	$48, %edx
	movq	%rax, %rcx
	movb	%dl, 11+x(%rip)
	testq	%rax, %rax
	je	.L17
	cqto
	idivq	%rsi
	addl	$48, %edx
	movq	%rax, %rcx
	movb	%dl, 10+x(%rip)
	testq	%rax, %rax
	je	.L18
	cqto
	idivq	%rsi
	addl	$48, %edx
	movq	%rax, %rcx
	movb	%dl, 9+x(%rip)
	testq	%rax, %rax
	je	.L19
	cqto
	idivq	%rsi
	addl	$48, %edx
	movq	%rax, %rcx
	movb	%dl, 8+x(%rip)
	testq	%rax, %rax
	je	.L20
	cqto
	idivq	%rsi
	addl	$48, %edx
	movq	%rax, %rcx
	movb	%dl, 7+x(%rip)
	testq	%rax, %rax
	je	.L21
	cqto
	idivq	%rsi
	addl	$48, %edx
	movq	%rax, %rcx
	movb	%dl, 6+x(%rip)
	testq	%rax, %rax
	je	.L22
	cqto
	idivq	%rsi
	addl	$48, %edx
	movq	%rax, %rcx
	movb	%dl, 5+x(%rip)
	testq	%rax, %rax
	je	.L23
	cqto
	idivq	%rsi
	addl	$48, %edx
	movq	%rax, %rcx
	movb	%dl, 4+x(%rip)
	testq	%rax, %rax
	je	.L24
	cqto
	idivq	%rsi
	addl	$48, %edx
	movq	%rax, %rcx
	movb	%dl, 3+x(%rip)
	testq	%rax, %rax
	je	.L25
	cqto
	idivq	%rsi
	addl	$48, %edx
	movq	%rax, %rcx
	movb	%dl, 2+x(%rip)
	testq	%rax, %rax
	je	.L26
	cqto
	idivq	%rsi
	addl	$48, %edx
	movq	%rax, %rcx
	movb	%dl, 1+x(%rip)
	testq	%rax, %rax
	je	.L27
	cqto
	idivq	%rsi
	addl	$48, %edx
	movq	%rax, %rcx
	xorl	%eax, %eax
	movb	%dl, x(%rip)
.L9:
	movl	$17, %edx
	movl	%eax, sz(%rip)
	movl	$1, %edi
	movq	%rcx, ans(%rip)
	leaq	x(%rip), %rcx
	subl	%eax, %edx
	leaq	(%rax,%rcx), %rsi
	xorl	%eax, %eax
	call	write@PLT
	popq	%rbx
	.cfi_remember_state
	.cfi_def_cfa_offset 24
	xorl	%eax, %eax
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L11:
	.cfi_restore_state
	xorl	%eax, %eax
	jmp	.L5
.L17:
	movl	$11, %eax
	jmp	.L9
.L12:
	movl	$16, %eax
	jmp	.L9
.L13:
	movl	$15, %eax
	jmp	.L9
.L14:
	movl	$14, %eax
	jmp	.L9
.L15:
	movl	$13, %eax
	jmp	.L9
.L16:
	movl	$12, %eax
	jmp	.L9
.L18:
	movl	$10, %eax
	jmp	.L9
.L25:
	movl	$3, %eax
	jmp	.L9
.L19:
	movl	$9, %eax
	jmp	.L9
.L20:
	movl	$8, %eax
	jmp	.L9
.L21:
	movl	$7, %eax
	jmp	.L9
.L22:
	movl	$6, %eax
	jmp	.L9
.L23:
	movl	$5, %eax
	jmp	.L9
.L24:
	movl	$4, %eax
	jmp	.L9
.L26:
	movl	$2, %eax
	jmp	.L9
.L27:
	movl	$1, %eax
	jmp	.L9
	.cfi_endproc
.LFE0:
	.size	main, .-main
	.globl	ans
	.bss
	.align 8
	.type	ans, @object
	.size	ans, 8
ans:
	.zero	8
	.globl	T
	.align 4
	.type	T, @object
	.size	T, 4
T:
	.zero	4
	.globl	p
	.align 4
	.type	p, @object
	.size	p, 4
p:
	.zero	4
	.globl	B
	.align 4
	.type	B, @object
	.size	B, 4
B:
	.zero	4
	.globl	A
	.align 4
	.type	A, @object
	.size	A, 4
A:
	.zero	4
	.globl	buf
	.align 32
	.type	buf, @object
	.size	buf, 2200000
buf:
	.zero	2200000
	.globl	x
	.align 16
	.type	x, @object
	.size	x, 18
x:
	.zero	18
	.globl	k
	.align 4
	.type	k, @object
	.size	k, 4
k:
	.zero	4
	.globl	sz
	.align 4
	.type	sz, @object
	.size	sz, 4
sz:
	.zero	4
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:

rule
	.file	"temp.c"
	.text
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	xorl	%edi, %edi
	movl	$2200000, %edx
	xorl	%eax, %eax
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	xorl	%r12d, %r12d
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	leaq	buf(%rip), %rbx
	movq	%rbx, %rsi
	call	read@PLT
	movq	ans(%rip), %r8
	leaq	1(%rbx), %rsi
	xorl	%r9d, %r9d
	leal	-2(%rax), %r10d
	movslq	%r10d, %rax
	movq	%r8, %rdi
	leal	-1(%r10), %r11d
	movsbl	(%rbx,%rax), %eax
	cmpl	$47, %eax
	jle	.L10
	.p2align 4,,10
	.p2align 3
.L35:
	subl	$2, %r10d
	xorl	%ecx, %ecx
	movl	$1, %edx
	movslq	%r10d, %r10
	.p2align 4,,10
	.p2align 3
.L3:
	subl	$48, %eax
	movl	%r10d, %r11d
	imull	%edx, %eax
	leal	(%rdx,%rdx,4), %edx
	addl	%edx, %edx
	addl	%eax, %ecx
	movsbl	(%rsi,%r10), %eax
	subq	$1, %r10
	cmpl	$47, %eax
	jg	.L3
	testl	%r11d, %r11d
	js	.L4
.L36:
	movslq	%r11d, %rax
	leal	-1(%r11), %r10d
	movsbl	(%rbx,%rax), %edx
	cmpl	$47, %edx
	jle	.L11
	leal	-2(%r11), %ebp
	xorl	%eax, %eax
	movl	$1, %r11d
	movslq	%ebp, %rbp
	.p2align 4,,10
	.p2align 3
.L6:
	subl	$48, %edx
	movl	%ebp, %r10d
	imull	%r11d, %edx
	leal	(%r11,%r11,4), %r11d
	addl	%r11d, %r11d
	addl	%edx, %eax
	movsbl	(%rsi,%rbp), %edx
	subq	$1, %rbp
	cmpl	$47, %edx
	jg	.L6
	negl	%eax
	cltq
.L5:
	subq	%rdi, %rax
	movslq	%ecx, %r11
	movl	$1, %r12d
	cqto
	idivq	%r11
	movslq	%r10d, %rax
	leal	-1(%r10), %r11d
	movsbl	(%rbx,%rax), %eax
	testl	%edx, %edx
	movl	%edx, %ebp
	cmovns	%r9d, %ecx
	addl	%edx, %ecx
	movslq	%ecx, %rcx
	addq	%rcx, %rdi
	cmpl	$47, %eax
	jg	.L35
.L10:
	xorl	%ecx, %ecx
	testl	%r11d, %r11d
	jns	.L36
	.p2align 4,,10
	.p2align 3
.L4:
	movl	%eax, k(%rip)
	movl	$1, p(%rip)
	movl	%ecx, B(%rip)
	movl	$0, A(%rip)
	testb	%r12b, %r12b
	je	.L8
	movl	%ebp, T(%rip)
	movq	%rdi, %r8
.L8:
	movabsq	$7378697629483820647, %rsi
	movq	%r8, %rax
	imulq	%rsi
	movq	%r8, %rax
	sarq	$63, %rax
	movq	%rdx, %rcx
	sarq	$2, %rcx
	subq	%rax, %rcx
	leaq	(%rcx,%rcx,4), %rax
	addq	%rax, %rax
	subq	%rax, %r8
	leal	48(%r8), %eax
	movb	%al, 16+x(%rip)
	testq	%rcx, %rcx
	je	.L12
	movq	%rcx, %rax
	imulq	%rsi
	movq	%rcx, %rax
	sarq	$63, %rax
	sarq	$2, %rdx
	subq	%rax, %rdx
	leaq	(%rdx,%rdx,4), %rax
	addq	%rax, %rax
	subq	%rax, %rcx
	leal	48(%rcx), %eax
	movq	%rdx, %rcx
	movb	%al, 15+x(%rip)
	testq	%rdx, %rdx
	je	.L13
	movq	%rdx, %rax
	imulq	%rsi
	movq	%rcx, %rax
	sarq	$63, %rax
	sarq	$2, %rdx
	subq	%rax, %rdx
	leaq	(%rdx,%rdx,4), %rax
	addq	%rax, %rax
	subq	%rax, %rcx
	leal	48(%rcx), %eax
	movq	%rdx, %rcx
	movb	%al, 14+x(%rip)
	testq	%rdx, %rdx
	je	.L14
	movq	%rdx, %rax
	imulq	%rsi
	movq	%rcx, %rax
	sarq	$63, %rax
	sarq	$2, %rdx
	subq	%rax, %rdx
	leaq	(%rdx,%rdx,4), %rax
	addq	%rax, %rax
	subq	%rax, %rcx
	leal	48(%rcx), %eax
	movq	%rdx, %rcx
	movb	%al, 13+x(%rip)
	testq	%rdx, %rdx
	je	.L15
	movq	%rdx, %rax
	movl	$10, %esi
	cqto
	idivq	%rsi
	addl	$48, %edx
	movq	%rax, %rcx
	movb	%dl, 12+x(%rip)
	testq	%rax, %rax
	je	.L16
	cqto
	idivq	%rsi
	addl	$48, %edx
	movq	%rax, %rcx
	movb	%dl, 11+x(%rip)
	testq	%rax, %rax
	je	.L17
	cqto
	idivq	%rsi
	addl	$48, %edx
	movq	%rax, %rcx
	movb	%dl, 10+x(%rip)
	testq	%rax, %rax
	je	.L18
	cqto
	idivq	%rsi
	addl	$48, %edx
	movq	%rax, %rcx
	movb	%dl, 9+x(%rip)
	testq	%rax, %rax
	je	.L19
	cqto
	idivq	%rsi
	addl	$48, %edx
	movq	%rax, %rcx
	movb	%dl, 8+x(%rip)
	testq	%rax, %rax
	je	.L20
	cqto
	idivq	%rsi
	addl	$48, %edx
	movq	%rax, %rcx
	movb	%dl, 7+x(%rip)
	testq	%rax, %rax
	je	.L21
	cqto
	idivq	%rsi
	addl	$48, %edx
	movq	%rax, %rcx
	movb	%dl, 6+x(%rip)
	testq	%rax, %rax
	je	.L22
	cqto
	idivq	%rsi
	addl	$48, %edx
	movq	%rax, %rcx
	movb	%dl, 5+x(%rip)
	testq	%rax, %rax
	je	.L23
	cqto
	idivq	%rsi
	addl	$48, %edx
	movq	%rax, %rcx
	movb	%dl, 4+x(%rip)
	testq	%rax, %rax
	je	.L24
	cqto
	idivq	%rsi
	addl	$48, %edx
	movq	%rax, %rcx
	movb	%dl, 3+x(%rip)
	testq	%rax, %rax
	je	.L25
	cqto
	idivq	%rsi
	addl	$48, %edx
	movq	%rax, %rcx
	movb	%dl, 2+x(%rip)
	testq	%rax, %rax
	je	.L26
	cqto
	idivq	%rsi
	addl	$48, %edx
	movq	%rax, %rcx
	movb	%dl, 1+x(%rip)
	testq	%rax, %rax
	je	.L27
	cqto
	idivq	%rsi
	addl	$48, %edx
	movq	%rax, %rcx
	xorl	%eax, %eax
	movb	%dl, x(%rip)
.L9:
	movl	$17, %edx
	movl	%eax, sz(%rip)
	movl	$1, %edi
	movq	%rcx, ans(%rip)
	leaq	x(%rip), %rcx
	subl	%eax, %edx
	leaq	(%rax,%rcx), %rsi
	xorl	%eax, %eax
	call	write@PLT
	popq	%rbx
	.cfi_remember_state
	.cfi_def_cfa_offset 24
	xorl	%eax, %eax
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L11:
	.cfi_restore_state
	xorl	%eax, %eax
	jmp	.L5
.L17:
	movl	$11, %eax
	jmp	.L9
.L12:
	movl	$16, %eax
	jmp	.L9
.L13:
	movl	$15, %eax
	jmp	.L9
.L14:
	movl	$14, %eax
	jmp	.L9
.L15:
	movl	$13, %eax
	jmp	.L9
.L16:
	movl	$12, %eax
	jmp	.L9
.L18:
	movl	$10, %eax
	jmp	.L9
.L25:
	movl	$3, %eax
	jmp	.L9
.L19:
	movl	$9, %eax
	jmp	.L9
.L20:
	movl	$8, %eax
	jmp	.L9
.L21:
	movl	$7, %eax
	jmp	.L9
.L22:
	movl	$6, %eax
	jmp	.L9
.L23:
	movl	$5, %eax
	jmp	.L9
.L24:
	movl	$4, %eax
	jmp	.L9
.L26:
	movl	$2, %eax
	jmp	.L9
.L27:
	movl	$1, %eax
	jmp	.L9
	.cfi_endproc
.LFE0:
	.size	main, .-main
	.globl	ans
	.bss
	.align 8
	.type	ans, @object
	.size	ans, 8
ans:
	.zero	8
	.globl	T
	.align 4
	.type	T, @object
	.size	T, 4
T:
	.zero	4
	.globl	p
	.align 4
	.type	p, @object
	.size	p, 4
p:
	.zero	4
	.globl	B
	.align 4
	.type	B, @object
	.size	B, 4
B:
	.zero	4
	.globl	A
	.align 4
	.type	A, @object
	.size	A, 4
A:
	.zero	4
	.globl	buf
	.align 32
	.type	buf, @object
	.size	buf, 2200000
buf:
	.zero	2200000
	.globl	x
	.align 16
	.type	x, @object
	.size	x, 18
x:
	.zero	18
	.globl	k
	.align 4
	.type	k, @object
	.size	k, 4
k:
	.zero	4
	.globl	sz
	.align 4
	.type	sz, @object
	.size	sz, 4
sz:
	.zero	4
	.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:

sz;
k;
char x[18],buf[2200000];
A,B,p,T;
long ans;
main()
{
	sz=read(0,buf,2200000);
	sz-=2;
	while(1)
	{
		A=B=0;
		p=1;
		while(1)
		{
			k=buf[sz--];
			if(k<'0')break;
			B+=(k-'0')*p;
			p*=10;
		}
		p=1;
		if(sz<0)break;
		while(1)
		{
			k=buf[sz--];
			if(k<'0')break;
			A+=(k-'0')*p;
			p*=10;
		}
		T=(-A-ans)%B;
		ans+=T+(T<0)*B;
	}
	sz=17;
	do
	{
		x[--sz]=ans%10+'0';
		ans/=10;
	}while(ans);
	write(1,x+sz,17-sz);
}
7
3 1
4 1
5 12
2 6
5 3
5 8
9 7
 3
3 5
2 2
9 4
 3
3 4
2 2
9 4
 3
2 4
2 1
9 4
 7
4 1
4 2
5 12
2 4
6 4
5 8
10 3
 7
4 1
4 2
5 12
2 4
6 1
5 8
13 6
 7
5 2
4 2
5 12
2 4
6 1
1 8
17 6
 7
3 1
4 1
5 9
2 6
5 3
5 8
6 7
 3
3 5
2 2
18 4
 7
4 1
4 1
6 12
2 4
6 3
5 8
10 7

19 7 5 6 8 20 21 4 2 18
Given the following C code and unoptimized assembly code, your task is to generate highly optimized x86-64 assembly code.
C Code:

```c
sz;
k;
char x[18],buf[2200000];
A,B,p,T;
long ans;
main()
{
	sz=read(0,buf,2200000);
	sz-=2;
	while(1)
	{
		A=B=0;
		p=1;
		while(1)
		{
			k=buf[sz--];
			if(k<'0')break;
			B+=(k-'0')*p;
			p*=10;
		}
		p=1;
		if(sz<0)break;
		while(1)
		{
			k=buf[sz--];
			if(k<'0')break;
			A+=(k-'0')*p;
			p*=10;
		}
		T=(-A-ans)%B;
		ans+=T+(T<0)*B;
	}
	sz=17;
	do
	{
		x[--sz]=ans%10+'0';
		ans/=10;
	}while(ans);
	write(1,x+sz,17-sz);
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	sz
	.bss
	.align 4
	.type	sz, @object
	.size	sz, 4
sz:
	.zero	4
	.globl	k
	.align 4
	.type	k, @object
	.size	k, 4
k:
	.zero	4
	.globl	x
	.align 16
	.type	x, @object
	.size	x, 18
x:
	.zero	18
	.globl	buf
	.align 32
	.type	buf, @object
	.size	buf, 2200000
buf:
	.zero	2200000
	.globl	A
	.align 4
	.type	A, @object
	.size	A, 4
A:
	.zero	4
	.globl	B
	.align 4
	.type	B, @object
	.size	B, 4
B:
	.zero	4
	.globl	p
	.align 4
	.type	p, @object
	.size	p, 4
p:
	.zero	4
	.globl	T
	.align 4
	.type	T, @object
	.size	T, 4
T:
	.zero	4
	.globl	ans
	.align 8
	.type	ans, @object
	.size	ans, 8
ans:
	.zero	8
	.text
	.globl	main
	.type	main, @function
main:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	$2200000, %edx
	leaq	buf(%rip), %rax
	movq	%rax, %rsi
	movl	$0, %edi
	movl	$0, %eax
	call	read@PLT
	movl	%eax, sz(%rip)
	movl	sz(%rip), %eax
	subl	$2, %eax
	movl	%eax, sz(%rip)
.L9:
	movl	$0, B(%rip)
	movl	B(%rip), %eax
	movl	%eax, A(%rip)
	movl	$1, p(%rip)
.L4:
	movl	sz(%rip), %eax
	leal	-1(%rax), %edx
	movl	%edx, sz(%rip)
	cltq
	leaq	buf(%rip), %rdx
	movzbl	(%rax,%rdx), %eax
	movsbl	%al, %eax
	movl	%eax, k(%rip)
	movl	k(%rip), %eax
	cmpl	$47, %eax
	jle	.L15
	movl	k(%rip), %eax
	leal	-48(%rax), %edx
	movl	p(%rip), %eax
	imull	%eax, %edx
	movl	B(%rip), %eax
	addl	%edx, %eax
	movl	%eax, B(%rip)
	movl	p(%rip), %edx
	movl	%edx, %eax
	sall	$2, %eax
	addl	%edx, %eax
	addl	%eax, %eax
	movl	%eax, p(%rip)
	jmp	.L4
.L15:
	nop
	movl	$1, p(%rip)
	movl	sz(%rip), %eax
	testl	%eax, %eax
	js	.L16
.L5:
	movl	sz(%rip), %eax
	leal	-1(%rax), %edx
	movl	%edx, sz(%rip)
	cltq
	leaq	buf(%rip), %rdx
	movzbl	(%rax,%rdx), %eax
	movsbl	%al, %eax
	movl	%eax, k(%rip)
	movl	k(%rip), %eax
	cmpl	$47, %eax
	jle	.L17
	movl	k(%rip), %eax
	leal	-48(%rax), %edx
	movl	p(%rip), %eax
	imull	%eax, %edx
	movl	A(%rip), %eax
	addl	%edx, %eax
	movl	%eax, A(%rip)
	movl	p(%rip), %edx
	movl	%edx, %eax
	sall	$2, %eax
	addl	%edx, %eax
	addl	%eax, %eax
	movl	%eax, p(%rip)
	jmp	.L5
.L17:
	nop
	movl	A(%rip), %eax
	negl	%eax
	cltq
	movq	ans(%rip), %rdx
	subq	%rdx, %rax
	movl	B(%rip), %edx
	movslq	%edx, %rcx
	cqto
	idivq	%rcx
	movq	%rdx, %rax
	movl	%eax, T(%rip)
	movl	T(%rip), %eax
	shrl	$31, %eax
	movzbl	%al, %edx
	movl	B(%rip), %eax
	imull	%eax, %edx
	movl	T(%rip), %eax
	addl	%edx, %eax
	movslq	%eax, %rdx
	movq	ans(%rip), %rax
	addq	%rdx, %rax
	movq	%rax, ans(%rip)
	jmp	.L9
.L16:
	nop
	movl	$17, sz(%rip)
.L10:
	movq	ans(%rip), %rcx
	movabsq	$7378697629483820647, %rdx
	movq	%rcx, %rax
	imulq	%rdx
	movq	%rdx, %rax
	sarq	$2, %rax
	movq	%rcx, %rsi
	sarq	$63, %rsi
	subq	%rsi, %rax
	movq	%rax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rax, %rax
	subq	%rax, %rcx
	movq	%rcx, %rdx
	movl	%edx, %eax
	leal	48(%rax), %edx
	movl	sz(%rip), %eax
	subl	$1, %eax
	movl	%eax, sz(%rip)
	movl	sz(%rip), %eax
	movl	%edx, %ecx
	cltq
	leaq	x(%rip), %rdx
	movb	%cl, (%rax,%rdx)
	movq	ans(%rip), %rcx
	movabsq	$7378697629483820647, %rdx
	movq	%rcx, %rax
	imulq	%rdx
	movq	%rdx, %rax
	sarq	$2, %rax
	sarq	$63, %rcx
	movq	%rcx, %rdx
	subq	%rdx, %rax
	movq	%rax, ans(%rip)
	movq	ans(%rip), %rax
	testq	%rax, %rax
	jne	.L10
	movl	sz(%rip), %eax
	movl	$17, %edx
	subl	%eax, %edx
	movl	sz(%rip), %eax
	cltq
	leaq	x(%rip), %rcx
	addq	%rcx, %rax
	movq	%rax, %rsi
	movl	$1, %edi
	movl	$0, %eax
	call	write@PLT
	movl	$0, %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.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.
val
	.file	"temp.c"
	.text
	.globl	sz
	.bss
	.align 4
	.type	sz, @object
	.size	sz, 4
sz:
	.zero	4
	.globl	k
	.align 4
	.type	k, @object
	.size	k, 4
k:
	.zero	4
	.globl	x
	.align 16
	.type	x, @object
	.size	x, 18
x:
	.zero	18
	.globl	buf
	.align 32
	.type	buf, @object
	.size	buf, 2200000
buf:
	.zero	2200000
	.globl	A
	.align 4
	.type	A, @object
	.size	A, 4
A:
	.zero	4
	.globl	B
	.align 4
	.type	B, @object
	.size	B, 4
B:
	.zero	4
	.globl	p
	.align 4
	.type	p, @object
	.size	p, 4
p:
	.zero	4
	.globl	T
	.align 4
	.type	T, @object
	.size	T, 4
T:
	.zero	4
	.globl	ans
	.align 8
	.type	ans, @object
	.size	ans, 8
ans:
	.zero	8
	.text
	.globl	main
	.type	main, @function
main:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	$2200000, %edx
	leaq	buf(%rip), %rax
	movq	%rax, %rsi
	movl	$0, %edi
	movl	$0, %eax
	call	read@PLT
	movl	%eax, sz(%rip)
	movl	sz(%rip), %eax
	subl	$2, %eax
	movl	%eax, sz(%rip)
.L9:
	movl	$0, B(%rip)
	movl	B(%rip), %eax
	movl	%eax, A(%rip)
	movl	$1, p(%rip)
.L4:
	movl	sz(%rip), %eax
	leal	-1(%rax), %edx
	movl	%edx, sz(%rip)
	cltq
	leaq	buf(%rip), %rdx
	movzbl	(%rax,%rdx), %eax
	movsbl	%al, %eax
	movl	%eax, k(%rip)
	movl	k(%rip), %eax
	cmpl	$47, %eax
	jle	.L15
	movl	k(%rip), %eax
	leal	-48(%rax), %edx
	movl	p(%rip), %eax
	imull	%eax, %edx
	movl	B(%rip), %eax
	addl	%edx, %eax
	movl	%eax, B(%rip)
	movl	p(%rip), %edx
	movl	%edx, %eax
	sall	$2, %eax
	addl	%edx, %eax
	addl	%eax, %eax
	movl	%eax, p(%rip)
	jmp	.L4
.L15:
	nop
	movl	$1, p(%rip)
	movl	sz(%rip), %eax
	testl	%eax, %eax
	js	.L16
.L5:
	movl	sz(%rip), %eax
	leal	-1(%rax), %edx
	movl	%edx, sz(%rip)
	cltq
	leaq	buf(%rip), %rdx
	movzbl	(%rax,%rdx), %eax
	movsbl	%al, %eax
	movl	%eax, k(%rip)
	movl	k(%rip), %eax
	cmpl	$47, %eax
	jle	.L17
	movl	k(%rip), %eax
	leal	-48(%rax), %edx
	movl	p(%rip), %eax
	imull	%eax, %edx
	movl	A(%rip), %eax
	addl	%edx, %eax
	movl	%eax, A(%rip)
	movl	p(%rip), %edx
	movl	%edx, %eax
	sall	$2, %eax
	addl	%edx, %eax
	addl	%eax, %eax
	movl	%eax, p(%rip)
	jmp	.L5
.L17:
	nop
	movl	A(%rip), %eax
	negl	%eax
	cltq
	movq	ans(%rip), %rdx
	subq	%rdx, %rax
	movl	B(%rip), %edx
	movslq	%edx, %rcx
	cqto
	idivq	%rcx
	movq	%rdx, %rax
	movl	%eax, T(%rip)
	movl	T(%rip), %eax
	shrl	$31, %eax
	movzbl	%al, %edx
	movl	B(%rip), %eax
	imull	%eax, %edx
	movl	T(%rip), %eax
	addl	%edx, %eax
	movslq	%eax, %rdx
	movq	ans(%rip), %rax
	addq	%rdx, %rax
	movq	%rax, ans(%rip)
	jmp	.L9
.L16:
	nop
	movl	$17, sz(%rip)
.L10:
	movq	ans(%rip), %rcx
	movabsq	$7378697629483820647, %rdx
	movq	%rcx, %rax
	imulq	%rdx
	movq	%rdx, %rax
	sarq	$2, %rax
	movq	%rcx, %rsi
	sarq	$63, %rsi
	subq	%rsi, %rax
	movq	%rax, %rdx
	movq	%rdx, %rax
	salq	$2, %rax
	addq	%rdx, %rax
	addq	%rax, %rax
	subq	%rax, %rcx
	movq	%rcx, %rdx
	movl	%edx, %eax
	leal	48(%rax), %edx
	movl	sz(%rip), %eax
	subl	$1, %eax
	movl	%eax, sz(%rip)
	movl	sz(%rip), %eax
	movl	%edx, %ecx
	cltq
	leaq	x(%rip), %rdx
	movb	%cl, (%rax,%rdx)
	movq	ans(%rip), %rcx
	movabsq	$7378697629483820647, %rdx
	movq	%rcx, %rax
	imulq	%rdx
	movq	%rdx, %rax
	sarq	$2, %rax
	sarq	$63, %rcx
	movq	%rcx, %rdx
	subq	%rdx, %rax
	movq	%rax, ans(%rip)
	movq	ans(%rip), %rax
	testq	%rax, %rax
	jne	.L10
	movl	sz(%rip), %eax
	movl	$17, %edx
	subl	%eax, %edx
	movl	sz(%rip), %eax
	cltq
	leaq	x(%rip), %rcx
	addq	%rcx, %rax
	movq	%rax, %rsi
	movl	$1, %edi
	movl	$0, %eax
	call	write@PLT
	movl	$0, %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.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:
