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

```c
// AOJ 0504: Card Game II
// 2017.12.6 bal4u@uu

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

#define N 6
char ans[10015];
int d[10015];

void calc(int b, int n)
{
	int i, a = 1;

	for (i = 0; i <= n; i++) {
		if (a >= b) d[i] += a / b, a %= b;
		if (!a) break;
		a *= 10;
	}
}

int main()
{
	int n, k, m, r, i;
	
	while (scanf("%d%d%d%d", &n, &k, &m, &r) && n > 0) {
		r += N;
		memset(d, 0, sizeof(d));
		calc(n, r);
		if (m == 1) for (k = n, i = 1; i < n; i++, k+=n) calc(k, r);
		for (k = 0, i = r; i >= 0; i--) {
			k += d[i];
			if (k >= 10) ans[i] = '0' + k % 10, k /= 10;
			else         ans[i] = '0' + k, k = 0;
		}
		ans[r-N+1] = 0;
		putchar(ans[0]), putchar('.'), puts(ans+1);
	}
	return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	ans
	.bss
	.align 32
	.type	ans, @object
	.size	ans, 10015
ans:
	.zero	10015
	.globl	d
	.align 32
	.type	d, @object
	.size	d, 40060
d:
	.zero	40060
	.text
	.globl	calc
	.type	calc, @function
calc:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	%edi, -20(%rbp)
	movl	%esi, -24(%rbp)
	movl	$1, -4(%rbp)
	movl	$0, -8(%rbp)
	jmp	.L2
.L6:
	movl	-4(%rbp), %eax
	cmpl	-20(%rbp), %eax
	jl	.L3
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	d(%rip), %rax
	movl	(%rdx,%rax), %ecx
	movl	-4(%rbp), %eax
	cltd
	idivl	-20(%rbp)
	addl	%eax, %ecx
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	d(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	movl	-4(%rbp), %eax
	cltd
	idivl	-20(%rbp)
	movl	%edx, -4(%rbp)
.L3:
	cmpl	$0, -4(%rbp)
	je	.L7
	movl	-4(%rbp), %edx
	movl	%edx, %eax
	sall	$2, %eax
	addl	%edx, %eax
	addl	%eax, %eax
	movl	%eax, -4(%rbp)
	addl	$1, -8(%rbp)
.L2:
	movl	-8(%rbp), %eax
	cmpl	-24(%rbp), %eax
	jle	.L6
	jmp	.L8
.L7:
	nop
.L8:
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	calc, .-calc
	.section	.rodata
.LC0:
	.string	"%d%d%d%d"
	.text
	.globl	main
	.type	main, @function
main:
.LFB1:
	.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	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	jmp	.L10
.L19:
	movl	-16(%rbp), %eax
	addl	$6, %eax
	movl	%eax, -16(%rbp)
	movl	$40060, %edx
	movl	$0, %esi
	leaq	d(%rip), %rax
	movq	%rax, %rdi
	call	memset@PLT
	movl	-16(%rbp), %edx
	movl	-28(%rbp), %eax
	movl	%edx, %esi
	movl	%eax, %edi
	call	calc
	movl	-20(%rbp), %eax
	cmpl	$1, %eax
	jne	.L11
	movl	-28(%rbp), %eax
	movl	%eax, -24(%rbp)
	movl	$1, -12(%rbp)
	jmp	.L12
.L13:
	movl	-16(%rbp), %edx
	movl	-24(%rbp), %eax
	movl	%edx, %esi
	movl	%eax, %edi
	call	calc
	addl	$1, -12(%rbp)
	movl	-24(%rbp), %edx
	movl	-28(%rbp), %eax
	addl	%edx, %eax
	movl	%eax, -24(%rbp)
.L12:
	movl	-28(%rbp), %eax
	cmpl	%eax, -12(%rbp)
	jl	.L13
.L11:
	movl	$0, -24(%rbp)
	movl	-16(%rbp), %eax
	movl	%eax, -12(%rbp)
	jmp	.L14
.L17:
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	d(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-24(%rbp), %eax
	addl	%edx, %eax
	movl	%eax, -24(%rbp)
	movl	-24(%rbp), %eax
	cmpl	$9, %eax
	jle	.L15
	movl	-24(%rbp), %edx
	movslq	%edx, %rax
	imulq	$1717986919, %rax, %rax
	shrq	$32, %rax
	sarl	$2, %eax
	movl	%edx, %esi
	sarl	$31, %esi
	subl	%esi, %eax
	movl	%eax, %ecx
	movl	%ecx, %eax
	sall	$2, %eax
	addl	%ecx, %eax
	addl	%eax, %eax
	movl	%edx, %ecx
	subl	%eax, %ecx
	movl	%ecx, %eax
	addl	$48, %eax
	movl	%eax, %ecx
	movl	-12(%rbp), %eax
	cltq
	leaq	ans(%rip), %rdx
	movb	%cl, (%rax,%rdx)
	movl	-24(%rbp), %eax
	movslq	%eax, %rdx
	imulq	$1717986919, %rdx, %rdx
	shrq	$32, %rdx
	sarl	$2, %edx
	sarl	$31, %eax
	movl	%eax, %ecx
	movl	%edx, %eax
	subl	%ecx, %eax
	movl	%eax, -24(%rbp)
	jmp	.L16
.L15:
	movl	-24(%rbp), %eax
	addl	$48, %eax
	movl	%eax, %ecx
	movl	-12(%rbp), %eax
	cltq
	leaq	ans(%rip), %rdx
	movb	%cl, (%rax,%rdx)
	movl	$0, -24(%rbp)
.L16:
	subl	$1, -12(%rbp)
.L14:
	cmpl	$0, -12(%rbp)
	jns	.L17
	movl	-16(%rbp), %eax
	subl	$5, %eax
	cltq
	leaq	ans(%rip), %rdx
	movb	$0, (%rax,%rdx)
	movzbl	ans(%rip), %eax
	movsbl	%al, %eax
	movl	%eax, %edi
	call	putchar@PLT
	movl	$46, %edi
	call	putchar@PLT
	leaq	1+ans(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
.L10:
	leaq	-16(%rbp), %rsi
	leaq	-20(%rbp), %rcx
	leaq	-24(%rbp), %rdx
	leaq	-28(%rbp), %rax
	movq	%rsi, %r8
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	testl	%eax, %eax
	je	.L18
	movl	-28(%rbp), %eax
	testl	%eax, %eax
	jg	.L19
.L18:
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L21
	call	__stack_chk_fail@PLT
.L21:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.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	calc
	.type	calc, @function
calc:
.LFB35:
	.cfi_startproc
	endbr64
	testl	%esi, %esi
	js	.L1
	xorl	%ecx, %ecx
	movl	$1, %eax
	leaq	d(%rip), %r8
	jmp	.L4
	.p2align 4,,10
	.p2align 3
.L3:
	leal	(%rax,%rax,4), %eax
	addq	$1, %rcx
	addl	%eax, %eax
	cmpl	%ecx, %esi
	jl	.L1
.L4:
	cmpl	%eax, %edi
	jg	.L3
	cltd
	idivl	%edi
	addl	%eax, (%r8,%rcx,4)
	movl	%edx, %eax
	testl	%edx, %edx
	jne	.L3
.L1:
	ret
	.cfi_endproc
.LFE35:
	.size	calc, .-calc
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d%d%d%d"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB36:
	.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
	leaq	d(%rip), %r12
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	leaq	ans(%rip), %rbp
	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	44(%rsp), %rax
	leaq	52(%rsp), %r15
	movq	%rax, 24(%rsp)
	leaq	40(%rsp), %rax
	leaq	48(%rsp), %r14
	movq	%rax, 16(%rsp)
	.p2align 4,,10
	.p2align 3
.L11:
	movq	24(%rsp), %rdx
	movq	16(%rsp), %rsi
	xorl	%eax, %eax
	movq	%r15, %r8
	movq	%r14, %rcx
	leaq	.LC0(%rip), %rdi
	call	__isoc99_scanf@PLT
	testl	%eax, %eax
	je	.L26
	movl	40(%rsp), %r13d
	testl	%r13d, %r13d
	jle	.L26
	movl	52(%rsp), %r11d
	xorl	%esi, %esi
	movl	$40060, %edx
	movq	%r12, %rdi
	leal	6(%r11), %ebx
	movl	%r11d, 12(%rsp)
	movl	%ebx, 52(%rsp)
	call	memset@PLT
	testl	%ebx, %ebx
	movl	48(%rsp), %esi
	movl	12(%rsp), %r11d
	js	.L12
	xorl	%ecx, %ecx
	movl	$1, %eax
	jmp	.L15
	.p2align 4,,10
	.p2align 3
.L13:
	leal	(%rax,%rax,4), %eax
	addq	$1, %rcx
	addl	%eax, %eax
	cmpl	%ecx, %ebx
	jl	.L14
.L15:
	cmpl	%eax, %r13d
	jg	.L13
	cltd
	idivl	%r13d
	addl	%eax, (%r12,%rcx,4)
	movl	%edx, %eax
	testl	%edx, %edx
	jne	.L13
.L14:
	cmpl	$1, %esi
	je	.L59
.L28:
	movslq	%ebx, %rbx
	.p2align 4,,10
	.p2align 3
.L58:
	xorl	%edx, %edx
.L25:
	movl	(%r12,%rbx,4), %eax
	addl	%edx, %eax
	cmpl	$9, %eax
	jle	.L22
	movslq	%eax, %rdx
	movl	%eax, %ecx
	imulq	$1717986919, %rdx, %rdx
	sarl	$31, %ecx
	sarq	$34, %rdx
	subl	%ecx, %edx
	leal	(%rdx,%rdx,4), %ecx
	addl	%ecx, %ecx
	subl	%ecx, %eax
	addl	$48, %eax
	movb	%al, 0(%rbp,%rbx)
	subq	$1, %rbx
	testl	%ebx, %ebx
	jns	.L25
.L24:
	movl	%edx, 44(%rsp)
.L21:
	addl	$1, %r11d
	movq	stdout(%rip), %rsi
	movslq	%r11d, %r11
	movb	$0, 0(%rbp,%r11)
	movsbl	0(%rbp), %edi
	call	putc@PLT
	movq	stdout(%rip), %rsi
	movl	$46, %edi
	call	putc@PLT
	leaq	1+ans(%rip), %rdi
	call	puts@PLT
	jmp	.L11
	.p2align 4,,10
	.p2align 3
.L22:
	addl	$48, %eax
	movb	%al, 0(%rbp,%rbx)
	subq	$1, %rbx
	testl	%ebx, %ebx
	jns	.L58
	xorl	%edx, %edx
	jmp	.L24
	.p2align 4,,10
	.p2align 3
.L59:
	cmpl	$1, %r13d
	je	.L28
.L33:
	movl	%r13d, %esi
	movl	$1, %edi
	.p2align 4,,10
	.p2align 3
.L17:
	xorl	%ecx, %ecx
	movl	$1, %eax
	testl	%ebx, %ebx
	jns	.L16
	jmp	.L20
	.p2align 4,,10
	.p2align 3
.L19:
	leal	(%rax,%rax,4), %eax
	addq	$1, %rcx
	addl	%eax, %eax
	cmpl	%ecx, %ebx
	jl	.L20
.L16:
	cmpl	%eax, %esi
	jg	.L19
	cltd
	idivl	%esi
	addl	%eax, (%r12,%rcx,4)
	movl	%edx, %eax
	testl	%edx, %edx
	jne	.L19
.L20:
	addl	$1, %edi
	addl	%r13d, %esi
	cmpl	%edi, %r13d
	jne	.L17
	movl	$0, 44(%rsp)
	testl	%ebx, %ebx
	jns	.L28
	jmp	.L21
.L26:
	movq	56(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L60
	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
.L12:
	.cfi_restore_state
	subl	$1, %esi
	je	.L61
.L56:
	movl	$0, 44(%rsp)
	jmp	.L21
.L61:
	cmpl	$1, %r13d
	jne	.L33
	jmp	.L56
.L60:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE36:
	.size	main, .-main
	.globl	d
	.bss
	.align 32
	.type	d, @object
	.size	d, 40060
d:
	.zero	40060
	.globl	ans
	.align 32
	.type	ans, @object
	.size	ans, 10015
ans:
	.zero	10015
	.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	calc
	.type	calc, @function
calc:
.LFB35:
	.cfi_startproc
	endbr64
	testl	%esi, %esi
	js	.L1
	xorl	%ecx, %ecx
	movl	$1, %eax
	leaq	d(%rip), %r8
	jmp	.L4
	.p2align 4,,10
	.p2align 3
.L3:
	leal	(%rax,%rax,4), %eax
	addq	$1, %rcx
	addl	%eax, %eax
	cmpl	%ecx, %esi
	jl	.L1
.L4:
	cmpl	%eax, %edi
	jg	.L3
	cltd
	idivl	%edi
	addl	%eax, (%r8,%rcx,4)
	movl	%edx, %eax
	testl	%edx, %edx
	jne	.L3
.L1:
	ret
	.cfi_endproc
.LFE35:
	.size	calc, .-calc
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d%d%d%d"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB36:
	.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
	leaq	d(%rip), %r12
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	leaq	ans(%rip), %rbp
	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	44(%rsp), %rax
	leaq	52(%rsp), %r15
	movq	%rax, 24(%rsp)
	leaq	40(%rsp), %rax
	leaq	48(%rsp), %r14
	movq	%rax, 16(%rsp)
	.p2align 4,,10
	.p2align 3
.L11:
	movq	24(%rsp), %rdx
	movq	16(%rsp), %rsi
	xorl	%eax, %eax
	movq	%r15, %r8
	movq	%r14, %rcx
	leaq	.LC0(%rip), %rdi
	call	__isoc99_scanf@PLT
	testl	%eax, %eax
	je	.L26
	movl	40(%rsp), %r13d
	testl	%r13d, %r13d
	jle	.L26
	movl	52(%rsp), %r11d
	xorl	%esi, %esi
	movl	$40060, %edx
	movq	%r12, %rdi
	leal	6(%r11), %ebx
	movl	%r11d, 12(%rsp)
	movl	%ebx, 52(%rsp)
	call	memset@PLT
	testl	%ebx, %ebx
	movl	48(%rsp), %esi
	movl	12(%rsp), %r11d
	js	.L12
	xorl	%ecx, %ecx
	movl	$1, %eax
	jmp	.L15
	.p2align 4,,10
	.p2align 3
.L13:
	leal	(%rax,%rax,4), %eax
	addq	$1, %rcx
	addl	%eax, %eax
	cmpl	%ecx, %ebx
	jl	.L14
.L15:
	cmpl	%eax, %r13d
	jg	.L13
	cltd
	idivl	%r13d
	addl	%eax, (%r12,%rcx,4)
	movl	%edx, %eax
	testl	%edx, %edx
	jne	.L13
.L14:
	cmpl	$1, %esi
	je	.L59
.L28:
	movslq	%ebx, %rbx
	.p2align 4,,10
	.p2align 3
.L58:
	xorl	%edx, %edx
.L25:
	movl	(%r12,%rbx,4), %eax
	addl	%edx, %eax
	cmpl	$9, %eax
	jle	.L22
	movslq	%eax, %rdx
	movl	%eax, %ecx
	imulq	$1717986919, %rdx, %rdx
	sarl	$31, %ecx
	sarq	$34, %rdx
	subl	%ecx, %edx
	leal	(%rdx,%rdx,4), %ecx
	addl	%ecx, %ecx
	subl	%ecx, %eax
	addl	$48, %eax
	movb	%al, 0(%rbp,%rbx)
	subq	$1, %rbx
	testl	%ebx, %ebx
	jns	.L25
.L24:
	movl	%edx, 44(%rsp)
.L21:
	addl	$1, %r11d
	movq	stdout(%rip), %rsi
	movslq	%r11d, %r11
	movb	$0, 0(%rbp,%r11)
	movsbl	0(%rbp), %edi
	call	putc@PLT
	movq	stdout(%rip), %rsi
	movl	$46, %edi
	call	putc@PLT
	leaq	1+ans(%rip), %rdi
	call	puts@PLT
	jmp	.L11
	.p2align 4,,10
	.p2align 3
.L22:
	addl	$48, %eax
	movb	%al, 0(%rbp,%rbx)
	subq	$1, %rbx
	testl	%ebx, %ebx
	jns	.L58
	xorl	%edx, %edx
	jmp	.L24
	.p2align 4,,10
	.p2align 3
.L59:
	cmpl	$1, %r13d
	je	.L28
.L33:
	movl	%r13d, %esi
	movl	$1, %edi
	.p2align 4,,10
	.p2align 3
.L17:
	xorl	%ecx, %ecx
	movl	$1, %eax
	testl	%ebx, %ebx
	jns	.L16
	jmp	.L20
	.p2align 4,,10
	.p2align 3
.L19:
	leal	(%rax,%rax,4), %eax
	addq	$1, %rcx
	addl	%eax, %eax
	cmpl	%ecx, %ebx
	jl	.L20
.L16:
	cmpl	%eax, %esi
	jg	.L19
	cltd
	idivl	%esi
	addl	%eax, (%r12,%rcx,4)
	movl	%edx, %eax
	testl	%edx, %edx
	jne	.L19
.L20:
	addl	$1, %edi
	addl	%r13d, %esi
	cmpl	%edi, %r13d
	jne	.L17
	movl	$0, 44(%rsp)
	testl	%ebx, %ebx
	jns	.L28
	jmp	.L21
.L26:
	movq	56(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L60
	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
.L12:
	.cfi_restore_state
	subl	$1, %esi
	je	.L61
.L56:
	movl	$0, 44(%rsp)
	jmp	.L21
.L61:
	cmpl	$1, %r13d
	jne	.L33
	jmp	.L56
.L60:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE36:
	.size	main, .-main
	.globl	d
	.bss
	.align 32
	.type	d, @object
	.size	d, 40060
d:
	.zero	40060
	.globl	ans
	.align 32
	.type	ans, @object
	.size	ans, 10015
ans:
	.zero	10015
	.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 0504: Card Game II
// 2017.12.6 bal4u@uu

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

#define N 6
char ans[10015];
int d[10015];

void calc(int b, int n)
{
	int i, a = 1;

	for (i = 0; i <= n; i++) {
		if (a >= b) d[i] += a / b, a %= b;
		if (!a) break;
		a *= 10;
	}
}

int main()
{
	int n, k, m, r, i;
	
	while (scanf("%d%d%d%d", &n, &k, &m, &r) && n > 0) {
		r += N;
		memset(d, 0, sizeof(d));
		calc(n, r);
		if (m == 1) for (k = n, i = 1; i < n; i++, k+=n) calc(k, r);
		for (k = 0, i = r; i >= 0; i--) {
			k += d[i];
			if (k >= 10) ans[i] = '0' + k % 10, k /= 10;
			else         ans[i] = '0' + k, k = 0;
		}
		ans[r-N+1] = 0;
		putchar(ans[0]), putchar('.'), puts(ans+1);
	}
	return 0;
}
2 1 0 5
3 1 2 3
2 2 1 3
0 0 0 0
 2 1 0 5
3 1 2 0
2 2 1 3
0 0 0 0
 2 1 0 5
3 1 2 6
2 2 1 3
0 0 0 0
 2 1 0 7
3 1 0 0
2 2 1 3
0 0 0 0
 2 1 0 1
2 1 0 0
2 2 1 3
0 0 0 0
 2 1 -1 5
4 1 2 0
2 2 1 3
0 0 0 0
 2 1 0 1
2 1 0 0
2 2 1 4
0 0 0 0
 2 1 0 5
4 1 -1 1
2 2 1 3
0 0 0 0
 2 1 0 1
2 1 -1 0
2 2 1 4
0 0 0 0
 2 1 0 1
4 1 -1 1
2 2 1 3
0 0 0 0

0.50000
0.333
1.000
 0.50000
0.
1.000
 0.50000
0.333333
1.000
 0.5000000
0.
1.000
 0.5
0.
1.000
 0.50000
0.
1.000
 0.5
0.
1.0000
 0.50000
0.2
1.000
 0.5
0.
1.0000
 0.5
0.2
1.000

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

```c
// AOJ 0504: Card Game II
// 2017.12.6 bal4u@uu

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

#define N 6
char ans[10015];
int d[10015];

void calc(int b, int n)
{
	int i, a = 1;

	for (i = 0; i <= n; i++) {
		if (a >= b) d[i] += a / b, a %= b;
		if (!a) break;
		a *= 10;
	}
}

int main()
{
	int n, k, m, r, i;
	
	while (scanf("%d%d%d%d", &n, &k, &m, &r) && n > 0) {
		r += N;
		memset(d, 0, sizeof(d));
		calc(n, r);
		if (m == 1) for (k = n, i = 1; i < n; i++, k+=n) calc(k, r);
		for (k = 0, i = r; i >= 0; i--) {
			k += d[i];
			if (k >= 10) ans[i] = '0' + k % 10, k /= 10;
			else         ans[i] = '0' + k, k = 0;
		}
		ans[r-N+1] = 0;
		putchar(ans[0]), putchar('.'), puts(ans+1);
	}
	return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	ans
	.bss
	.align 32
	.type	ans, @object
	.size	ans, 10015
ans:
	.zero	10015
	.globl	d
	.align 32
	.type	d, @object
	.size	d, 40060
d:
	.zero	40060
	.text
	.globl	calc
	.type	calc, @function
calc:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	%edi, -20(%rbp)
	movl	%esi, -24(%rbp)
	movl	$1, -4(%rbp)
	movl	$0, -8(%rbp)
	jmp	.L2
.L6:
	movl	-4(%rbp), %eax
	cmpl	-20(%rbp), %eax
	jl	.L3
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	d(%rip), %rax
	movl	(%rdx,%rax), %ecx
	movl	-4(%rbp), %eax
	cltd
	idivl	-20(%rbp)
	addl	%eax, %ecx
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	d(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	movl	-4(%rbp), %eax
	cltd
	idivl	-20(%rbp)
	movl	%edx, -4(%rbp)
.L3:
	cmpl	$0, -4(%rbp)
	je	.L7
	movl	-4(%rbp), %edx
	movl	%edx, %eax
	sall	$2, %eax
	addl	%edx, %eax
	addl	%eax, %eax
	movl	%eax, -4(%rbp)
	addl	$1, -8(%rbp)
.L2:
	movl	-8(%rbp), %eax
	cmpl	-24(%rbp), %eax
	jle	.L6
	jmp	.L8
.L7:
	nop
.L8:
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	calc, .-calc
	.section	.rodata
.LC0:
	.string	"%d%d%d%d"
	.text
	.globl	main
	.type	main, @function
main:
.LFB1:
	.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	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	jmp	.L10
.L19:
	movl	-16(%rbp), %eax
	addl	$6, %eax
	movl	%eax, -16(%rbp)
	movl	$40060, %edx
	movl	$0, %esi
	leaq	d(%rip), %rax
	movq	%rax, %rdi
	call	memset@PLT
	movl	-16(%rbp), %edx
	movl	-28(%rbp), %eax
	movl	%edx, %esi
	movl	%eax, %edi
	call	calc
	movl	-20(%rbp), %eax
	cmpl	$1, %eax
	jne	.L11
	movl	-28(%rbp), %eax
	movl	%eax, -24(%rbp)
	movl	$1, -12(%rbp)
	jmp	.L12
.L13:
	movl	-16(%rbp), %edx
	movl	-24(%rbp), %eax
	movl	%edx, %esi
	movl	%eax, %edi
	call	calc
	addl	$1, -12(%rbp)
	movl	-24(%rbp), %edx
	movl	-28(%rbp), %eax
	addl	%edx, %eax
	movl	%eax, -24(%rbp)
.L12:
	movl	-28(%rbp), %eax
	cmpl	%eax, -12(%rbp)
	jl	.L13
.L11:
	movl	$0, -24(%rbp)
	movl	-16(%rbp), %eax
	movl	%eax, -12(%rbp)
	jmp	.L14
.L17:
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	d(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-24(%rbp), %eax
	addl	%edx, %eax
	movl	%eax, -24(%rbp)
	movl	-24(%rbp), %eax
	cmpl	$9, %eax
	jle	.L15
	movl	-24(%rbp), %edx
	movslq	%edx, %rax
	imulq	$1717986919, %rax, %rax
	shrq	$32, %rax
	sarl	$2, %eax
	movl	%edx, %esi
	sarl	$31, %esi
	subl	%esi, %eax
	movl	%eax, %ecx
	movl	%ecx, %eax
	sall	$2, %eax
	addl	%ecx, %eax
	addl	%eax, %eax
	movl	%edx, %ecx
	subl	%eax, %ecx
	movl	%ecx, %eax
	addl	$48, %eax
	movl	%eax, %ecx
	movl	-12(%rbp), %eax
	cltq
	leaq	ans(%rip), %rdx
	movb	%cl, (%rax,%rdx)
	movl	-24(%rbp), %eax
	movslq	%eax, %rdx
	imulq	$1717986919, %rdx, %rdx
	shrq	$32, %rdx
	sarl	$2, %edx
	sarl	$31, %eax
	movl	%eax, %ecx
	movl	%edx, %eax
	subl	%ecx, %eax
	movl	%eax, -24(%rbp)
	jmp	.L16
.L15:
	movl	-24(%rbp), %eax
	addl	$48, %eax
	movl	%eax, %ecx
	movl	-12(%rbp), %eax
	cltq
	leaq	ans(%rip), %rdx
	movb	%cl, (%rax,%rdx)
	movl	$0, -24(%rbp)
.L16:
	subl	$1, -12(%rbp)
.L14:
	cmpl	$0, -12(%rbp)
	jns	.L17
	movl	-16(%rbp), %eax
	subl	$5, %eax
	cltq
	leaq	ans(%rip), %rdx
	movb	$0, (%rax,%rdx)
	movzbl	ans(%rip), %eax
	movsbl	%al, %eax
	movl	%eax, %edi
	call	putchar@PLT
	movl	$46, %edi
	call	putchar@PLT
	leaq	1+ans(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
.L10:
	leaq	-16(%rbp), %rsi
	leaq	-20(%rbp), %rcx
	leaq	-24(%rbp), %rdx
	leaq	-28(%rbp), %rax
	movq	%rsi, %r8
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	testl	%eax, %eax
	je	.L18
	movl	-28(%rbp), %eax
	testl	%eax, %eax
	jg	.L19
.L18:
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L21
	call	__stack_chk_fail@PLT
.L21:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.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	ans
	.bss
	.align 32
	.type	ans, @object
	.size	ans, 10015
ans:
	.zero	10015
	.globl	d
	.align 32
	.type	d, @object
	.size	d, 40060
d:
	.zero	40060
	.text
	.globl	calc
	.type	calc, @function
calc:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	%edi, -20(%rbp)
	movl	%esi, -24(%rbp)
	movl	$1, -4(%rbp)
	movl	$0, -8(%rbp)
	jmp	.L2
.L6:
	movl	-4(%rbp), %eax
	cmpl	-20(%rbp), %eax
	jl	.L3
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	d(%rip), %rax
	movl	(%rdx,%rax), %ecx
	movl	-4(%rbp), %eax
	cltd
	idivl	-20(%rbp)
	addl	%eax, %ecx
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	d(%rip), %rax
	movl	%ecx, (%rdx,%rax)
	movl	-4(%rbp), %eax
	cltd
	idivl	-20(%rbp)
	movl	%edx, -4(%rbp)
.L3:
	cmpl	$0, -4(%rbp)
	je	.L7
	movl	-4(%rbp), %edx
	movl	%edx, %eax
	sall	$2, %eax
	addl	%edx, %eax
	addl	%eax, %eax
	movl	%eax, -4(%rbp)
	addl	$1, -8(%rbp)
.L2:
	movl	-8(%rbp), %eax
	cmpl	-24(%rbp), %eax
	jle	.L6
	jmp	.L8
.L7:
	nop
.L8:
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	calc, .-calc
	.section	.rodata
.LC0:
	.string	"%d%d%d%d"
	.text
	.globl	main
	.type	main, @function
main:
.LFB1:
	.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	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	jmp	.L10
.L19:
	movl	-16(%rbp), %eax
	addl	$6, %eax
	movl	%eax, -16(%rbp)
	movl	$40060, %edx
	movl	$0, %esi
	leaq	d(%rip), %rax
	movq	%rax, %rdi
	call	memset@PLT
	movl	-16(%rbp), %edx
	movl	-28(%rbp), %eax
	movl	%edx, %esi
	movl	%eax, %edi
	call	calc
	movl	-20(%rbp), %eax
	cmpl	$1, %eax
	jne	.L11
	movl	-28(%rbp), %eax
	movl	%eax, -24(%rbp)
	movl	$1, -12(%rbp)
	jmp	.L12
.L13:
	movl	-16(%rbp), %edx
	movl	-24(%rbp), %eax
	movl	%edx, %esi
	movl	%eax, %edi
	call	calc
	addl	$1, -12(%rbp)
	movl	-24(%rbp), %edx
	movl	-28(%rbp), %eax
	addl	%edx, %eax
	movl	%eax, -24(%rbp)
.L12:
	movl	-28(%rbp), %eax
	cmpl	%eax, -12(%rbp)
	jl	.L13
.L11:
	movl	$0, -24(%rbp)
	movl	-16(%rbp), %eax
	movl	%eax, -12(%rbp)
	jmp	.L14
.L17:
	movl	-12(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	leaq	d(%rip), %rax
	movl	(%rdx,%rax), %edx
	movl	-24(%rbp), %eax
	addl	%edx, %eax
	movl	%eax, -24(%rbp)
	movl	-24(%rbp), %eax
	cmpl	$9, %eax
	jle	.L15
	movl	-24(%rbp), %edx
	movslq	%edx, %rax
	imulq	$1717986919, %rax, %rax
	shrq	$32, %rax
	sarl	$2, %eax
	movl	%edx, %esi
	sarl	$31, %esi
	subl	%esi, %eax
	movl	%eax, %ecx
	movl	%ecx, %eax
	sall	$2, %eax
	addl	%ecx, %eax
	addl	%eax, %eax
	movl	%edx, %ecx
	subl	%eax, %ecx
	movl	%ecx, %eax
	addl	$48, %eax
	movl	%eax, %ecx
	movl	-12(%rbp), %eax
	cltq
	leaq	ans(%rip), %rdx
	movb	%cl, (%rax,%rdx)
	movl	-24(%rbp), %eax
	movslq	%eax, %rdx
	imulq	$1717986919, %rdx, %rdx
	shrq	$32, %rdx
	sarl	$2, %edx
	sarl	$31, %eax
	movl	%eax, %ecx
	movl	%edx, %eax
	subl	%ecx, %eax
	movl	%eax, -24(%rbp)
	jmp	.L16
.L15:
	movl	-24(%rbp), %eax
	addl	$48, %eax
	movl	%eax, %ecx
	movl	-12(%rbp), %eax
	cltq
	leaq	ans(%rip), %rdx
	movb	%cl, (%rax,%rdx)
	movl	$0, -24(%rbp)
.L16:
	subl	$1, -12(%rbp)
.L14:
	cmpl	$0, -12(%rbp)
	jns	.L17
	movl	-16(%rbp), %eax
	subl	$5, %eax
	cltq
	leaq	ans(%rip), %rdx
	movb	$0, (%rax,%rdx)
	movzbl	ans(%rip), %eax
	movsbl	%al, %eax
	movl	%eax, %edi
	call	putchar@PLT
	movl	$46, %edi
	call	putchar@PLT
	leaq	1+ans(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
.L10:
	leaq	-16(%rbp), %rsi
	leaq	-20(%rbp), %rcx
	leaq	-24(%rbp), %rdx
	leaq	-28(%rbp), %rax
	movq	%rsi, %r8
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	testl	%eax, %eax
	je	.L18
	movl	-28(%rbp), %eax
	testl	%eax, %eax
	jg	.L19
.L18:
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L21
	call	__stack_chk_fail@PLT
.L21:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE1:
	.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:
