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

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

/* typedef */

typedef unsigned long long ull_t;

/* main */

int main(int argc, char **argv) {
  ull_t n, hn, count, x, cn;
  double hnf;

  for (;;) {
    scanf("%llu", &n);
    if (n == 0) break;

    hn = n / 2;

    count = hn;
    for (x = 1; x * x < hn; x++)
      count += (hn + x - 1) / x;

    cn = 0;
    while (cn * cn < hn) cn++;

    printf("%llu\n", 2 * (8 * count - 4 * cn * cn) + 8 * n);
  }

  return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%llu"
.LC1:
	.string	"%llu\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB6:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$64, %rsp
	movl	%edi, -52(%rbp)
	movq	%rsi, -64(%rbp)
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
.L8:
	leaq	-48(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movq	-48(%rbp), %rax
	testq	%rax, %rax
	je	.L12
	movq	-48(%rbp), %rax
	shrq	%rax
	movq	%rax, -16(%rbp)
	movq	-16(%rbp), %rax
	movq	%rax, -40(%rbp)
	movq	$1, -32(%rbp)
	jmp	.L4
.L5:
	movq	-16(%rbp), %rdx
	movq	-32(%rbp), %rax
	addq	%rdx, %rax
	subq	$1, %rax
	movl	$0, %edx
	divq	-32(%rbp)
	addq	%rax, -40(%rbp)
	addq	$1, -32(%rbp)
.L4:
	movq	-32(%rbp), %rax
	imulq	%rax, %rax
	cmpq	%rax, -16(%rbp)
	ja	.L5
	movq	$0, -24(%rbp)
	jmp	.L6
.L7:
	addq	$1, -24(%rbp)
.L6:
	movq	-24(%rbp), %rax
	imulq	%rax, %rax
	cmpq	%rax, -16(%rbp)
	ja	.L7
	movq	-40(%rbp), %rax
	leaq	(%rax,%rax), %rdx
	movq	-24(%rbp), %rax
	imulq	%rax, %rax
	subq	%rax, %rdx
	movq	-48(%rbp), %rax
	addq	%rdx, %rax
	salq	$3, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L8
.L12:
	nop
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L10
	call	__stack_chk_fail@PLT
.L10:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.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	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%llu"
.LC1:
	.string	"%llu\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB39:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	leaq	.LC1(%rip), %r12
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	leaq	.LC0(%rip), %rbx
	subq	$16, %rsp
	.cfi_def_cfa_offset 48
	movq	%fs:40, %rax
	movq	%rax, 8(%rsp)
	xorl	%eax, %eax
	movq	%rsp, %rbp
	.p2align 4,,10
	.p2align 3
.L7:
	movq	%rbp, %rsi
	movq	%rbx, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movq	(%rsp), %r9
	testq	%r9, %r9
	je	.L2
	movq	%r9, %rsi
	shrq	%rsi
	cmpq	$1, %rsi
	jbe	.L3
	leaq	-1(%rsi), %r8
	movq	%rsi, %rdi
	movl	$1, %ecx
	.p2align 4,,10
	.p2align 3
.L4:
	leaq	(%rcx,%r8), %rax
	xorl	%edx, %edx
	divq	%rcx
	addq	$1, %rcx
	addq	%rax, %rdi
	movq	%rcx, %rax
	imulq	%rcx, %rax
	cmpq	%rsi, %rax
	jb	.L4
	xorl	%eax, %eax
	.p2align 4,,10
	.p2align 3
.L5:
	addq	$1, %rax
	movq	%rax, %rcx
	imulq	%rax, %rcx
	cmpq	%rsi, %rcx
	jb	.L5
.L6:
	leaq	(%r9,%rdi,2), %rdx
	movq	%r12, %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	subq	%rcx, %rdx
	salq	$3, %rdx
	call	__printf_chk@PLT
	jmp	.L7
	.p2align 4,,10
	.p2align 3
.L2:
	movq	8(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L14
	addq	$16, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 32
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L3:
	.cfi_restore_state
	sbbq	%rdi, %rdi
	addq	$1, %rdi
	cmpq	$1, %rsi
	sbbq	%rcx, %rcx
	addq	$1, %rcx
	jmp	.L6
.L14:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE39:
	.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:

rule
	.file	"temp.c"
	.text
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%llu"
.LC1:
	.string	"%llu\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB39:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	leaq	.LC1(%rip), %r12
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	leaq	.LC0(%rip), %rbx
	subq	$16, %rsp
	.cfi_def_cfa_offset 48
	movq	%fs:40, %rax
	movq	%rax, 8(%rsp)
	xorl	%eax, %eax
	movq	%rsp, %rbp
	.p2align 4,,10
	.p2align 3
.L7:
	movq	%rbp, %rsi
	movq	%rbx, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movq	(%rsp), %r9
	testq	%r9, %r9
	je	.L2
	movq	%r9, %rsi
	shrq	%rsi
	cmpq	$1, %rsi
	jbe	.L3
	leaq	-1(%rsi), %r8
	movq	%rsi, %rdi
	movl	$1, %ecx
	.p2align 4,,10
	.p2align 3
.L4:
	leaq	(%rcx,%r8), %rax
	xorl	%edx, %edx
	divq	%rcx
	addq	$1, %rcx
	addq	%rax, %rdi
	movq	%rcx, %rax
	imulq	%rcx, %rax
	cmpq	%rsi, %rax
	jb	.L4
	xorl	%eax, %eax
	.p2align 4,,10
	.p2align 3
.L5:
	addq	$1, %rax
	movq	%rax, %rcx
	imulq	%rax, %rcx
	cmpq	%rsi, %rcx
	jb	.L5
.L6:
	leaq	(%r9,%rdi,2), %rdx
	movq	%r12, %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	subq	%rcx, %rdx
	salq	$3, %rdx
	call	__printf_chk@PLT
	jmp	.L7
	.p2align 4,,10
	.p2align 3
.L2:
	movq	8(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L14
	addq	$16, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 32
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L3:
	.cfi_restore_state
	sbbq	%rdi, %rdi
	addq	$1, %rdi
	cmpq	$1, %rsi
	sbbq	%rcx, %rcx
	addq	$1, %rcx
	jmp	.L6
.L14:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE39:
	.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:

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

/* typedef */

typedef unsigned long long ull_t;

/* main */

int main(int argc, char **argv) {
  ull_t n, hn, count, x, cn;
  double hnf;

  for (;;) {
    scanf("%llu", &n);
    if (n == 0) break;

    hn = n / 2;

    count = hn;
    for (x = 1; x * x < hn; x++)
      count += (hn + x - 1) / x;

    cn = 0;
    while (cn * cn < hn) cn++;

    printf("%llu\n", 2 * (8 * count - 4 * cn * cn) + 8 * n);
  }

  return 0;
}
2
8
0
 2
6
0
 2
2
0
 2
0
0
 2
14
0
 2
12
0
 2
10
0
 2
18
0
 2
24
0
 2
0
1

24
160
 24
112
 24
24
 24
 24
328
 24
264
 24
216
 24
440
 24
608
 24

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

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

/* typedef */

typedef unsigned long long ull_t;

/* main */

int main(int argc, char **argv) {
  ull_t n, hn, count, x, cn;
  double hnf;

  for (;;) {
    scanf("%llu", &n);
    if (n == 0) break;

    hn = n / 2;

    count = hn;
    for (x = 1; x * x < hn; x++)
      count += (hn + x - 1) / x;

    cn = 0;
    while (cn * cn < hn) cn++;

    printf("%llu\n", 2 * (8 * count - 4 * cn * cn) + 8 * n);
  }

  return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%llu"
.LC1:
	.string	"%llu\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB6:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$64, %rsp
	movl	%edi, -52(%rbp)
	movq	%rsi, -64(%rbp)
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
.L8:
	leaq	-48(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movq	-48(%rbp), %rax
	testq	%rax, %rax
	je	.L12
	movq	-48(%rbp), %rax
	shrq	%rax
	movq	%rax, -16(%rbp)
	movq	-16(%rbp), %rax
	movq	%rax, -40(%rbp)
	movq	$1, -32(%rbp)
	jmp	.L4
.L5:
	movq	-16(%rbp), %rdx
	movq	-32(%rbp), %rax
	addq	%rdx, %rax
	subq	$1, %rax
	movl	$0, %edx
	divq	-32(%rbp)
	addq	%rax, -40(%rbp)
	addq	$1, -32(%rbp)
.L4:
	movq	-32(%rbp), %rax
	imulq	%rax, %rax
	cmpq	%rax, -16(%rbp)
	ja	.L5
	movq	$0, -24(%rbp)
	jmp	.L6
.L7:
	addq	$1, -24(%rbp)
.L6:
	movq	-24(%rbp), %rax
	imulq	%rax, %rax
	cmpq	%rax, -16(%rbp)
	ja	.L7
	movq	-40(%rbp), %rax
	leaq	(%rax,%rax), %rdx
	movq	-24(%rbp), %rax
	imulq	%rax, %rax
	subq	%rax, %rdx
	movq	-48(%rbp), %rax
	addq	%rdx, %rax
	salq	$3, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L8
.L12:
	nop
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L10
	call	__stack_chk_fail@PLT
.L10:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.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
	.section	.rodata
.LC0:
	.string	"%llu"
.LC1:
	.string	"%llu\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB6:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$64, %rsp
	movl	%edi, -52(%rbp)
	movq	%rsi, -64(%rbp)
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
.L8:
	leaq	-48(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movq	-48(%rbp), %rax
	testq	%rax, %rax
	je	.L12
	movq	-48(%rbp), %rax
	shrq	%rax
	movq	%rax, -16(%rbp)
	movq	-16(%rbp), %rax
	movq	%rax, -40(%rbp)
	movq	$1, -32(%rbp)
	jmp	.L4
.L5:
	movq	-16(%rbp), %rdx
	movq	-32(%rbp), %rax
	addq	%rdx, %rax
	subq	$1, %rax
	movl	$0, %edx
	divq	-32(%rbp)
	addq	%rax, -40(%rbp)
	addq	$1, -32(%rbp)
.L4:
	movq	-32(%rbp), %rax
	imulq	%rax, %rax
	cmpq	%rax, -16(%rbp)
	ja	.L5
	movq	$0, -24(%rbp)
	jmp	.L6
.L7:
	addq	$1, -24(%rbp)
.L6:
	movq	-24(%rbp), %rax
	imulq	%rax, %rax
	cmpq	%rax, -16(%rbp)
	ja	.L7
	movq	-40(%rbp), %rax
	leaq	(%rax,%rax), %rdx
	movq	-24(%rbp), %rax
	imulq	%rax, %rax
	subq	%rax, %rdx
	movq	-48(%rbp), %rax
	addq	%rdx, %rax
	salq	$3, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L8
.L12:
	nop
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L10
	call	__stack_chk_fail@PLT
.L10:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.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:
