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

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

int main()
{
	long long N;
	scanf("%lld", &N);
	
	long long n;
	for (n = 1; n * n < N; n *= 2);
	if (n * n - N > N - (n-1) * (n-1)) {
		for (n /= 2; n * n < N; n++);
		for (; N % n != 0; n--);
	} else {
		for (; n * n > N; n--);
		for (; N % n != 0; n--);
	}	
	
	printf("%lld\n", n + N / n - 2);
	fflush(stdout);
	return 0;
}```

Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%lld"
.LC1:
	.string	"%lld\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB39:
	.cfi_startproc
	endbr64
	subq	$24, %rsp
	.cfi_def_cfa_offset 32
	leaq	.LC0(%rip), %rdi
	movq	%fs:40, %rax
	movq	%rax, 8(%rsp)
	xorl	%eax, %eax
	movq	%rsp, %rsi
	call	__isoc99_scanf@PLT
	movq	(%rsp), %rsi
	movl	$1, %ecx
	cmpq	$1, %rsi
	jle	.L13
	.p2align 4,,10
	.p2align 3
.L3:
	addq	%rcx, %rcx
	movq	%rcx, %rdx
	imulq	%rcx, %rdx
	cmpq	%rsi, %rdx
	jl	.L3
.L2:
	leaq	-1(%rcx), %rax
	movq	%rsi, %rdi
	subq	%rsi, %rdx
	movq	%rax, %r8
	imulq	%rax, %r8
	subq	%r8, %rdi
	cmpq	%rdi, %rdx
	jg	.L4
	movq	%rcx, %rdx
	imulq	%rcx, %rdx
	cmpq	%rsi, %rdx
	jg	.L5
	jmp	.L6
	.p2align 4,,10
	.p2align 3
.L29:
	subq	$1, %rcx
.L6:
	movq	%rsi, %rax
	cqto
	idivq	%rcx
	testq	%rdx, %rdx
	jne	.L29
.L9:
	movq	%rsi, %rax
	movl	$1, %edi
	leaq	.LC1(%rip), %rsi
	cqto
	idivq	%rcx
	leaq	-2(%rcx,%rax), %rdx
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	stdout(%rip), %rdi
	call	fflush@PLT
	movq	8(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L30
	xorl	%eax, %eax
	addq	$24, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L31:
	.cfi_restore_state
	subq	$1, %rax
.L5:
	movq	%rax, %rdx
	movq	%rax, %rcx
	imulq	%rax, %rdx
	cmpq	%rsi, %rdx
	jg	.L31
	jmp	.L6
.L4:
	sarq	%rcx
	movq	%rcx, %rax
	imulq	%rcx, %rax
	cmpq	%rsi, %rax
	jge	.L7
.L8:
	addq	$1, %rcx
	movq	%rcx, %rax
	imulq	%rcx, %rax
	cmpq	%rsi, %rax
	jge	.L7
	addq	$1, %rcx
	movq	%rcx, %rax
	imulq	%rcx, %rax
	cmpq	%rsi, %rax
	jl	.L8
	jmp	.L7
	.p2align 4,,10
	.p2align 3
.L32:
	subq	$1, %rcx
.L7:
	movq	%rsi, %rax
	cqto
	idivq	%rcx
	testq	%rdx, %rdx
	jne	.L32
	jmp	.L9
.L13:
	movl	$1, %edx
	jmp	.L2
.L30:
	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:
```

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.
Optimized Assembly Code:

user
```assembly
	.file	"temp.c"
	.text
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%lld"
.LC1:
	.string	"%lld\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB39:
	.cfi_startproc
	endbr64
	subq	$24, %rsp
	.cfi_def_cfa_offset 32
	leaq	.LC0(%rip), %rdi
	movq	%fs:40, %rax
	movq	%rax, 8(%rsp)
	xorl	%eax, %eax
	movq	%rsp, %rsi
	call	__isoc99_scanf@PLT
	movq	(%rsp), %rsi
	movl	$1, %ecx
	cmpq	$1, %rsi
	jle	.L13
	.p2align 4,,10
	.p2align 3
.L3:
	addq	%rcx, %rcx
	movq	%rcx, %rdx
	imulq	%rcx, %rdx
	cmpq	%rsi, %rdx
	jl	.L3
.L2:
	leaq	-1(%rcx), %rax
	movq	%rsi, %rdi
	subq	%rsi, %rdx
	movq	%rax, %r8
	imulq	%rax, %r8
	subq	%r8, %rdi
	cmpq	%rdi, %rdx
	jg	.L4
	movq	%rcx, %rdx
	imulq	%rcx, %rdx
	cmpq	%rsi, %rdx
	jg	.L5
	jmp	.L6
	.p2align 4,,10
	.p2align 3
.L29:
	subq	$1, %rcx
.L6:
	movq	%rsi, %rax
	cqto
	idivq	%rcx
	testq	%rdx, %rdx
	jne	.L29
.L9:
	movq	%rsi, %rax
	movl	$1, %edi
	leaq	.LC1(%rip), %rsi
	cqto
	idivq	%rcx
	leaq	-2(%rcx,%rax), %rdx
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	stdout(%rip), %rdi
	call	fflush@PLT
	movq	8(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L30
	xorl	%eax, %eax
	addq	$24, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L31:
	.cfi_restore_state
	subq	$1, %rax
.L5:
	movq	%rax, %rdx
	movq	%rax, %rcx
	imulq	%rax, %rdx
	cmpq	%rsi, %rdx
	jg	.L31
	jmp	.L6
.L4:
	sarq	%rcx
	movq	%rcx, %rax
	imulq	%rcx, %rax
	cmpq	%rsi, %rax
	jge	.L7
.L8:
	addq	$1, %rcx
	movq	%rcx, %rax
	imulq	%rcx, %rax
	cmpq	%rsi, %rax
	jge	.L7
	addq	$1, %rcx
	movq	%rcx, %rax
	imulq	%rcx, %rax
	cmpq	%rsi, %rax
	jl	.L8
	jmp	.L7
	.p2align 4,,10
	.p2align 3
.L32:
	subq	$1, %rcx
.L7:
	movq	%rsi, %rax
	cqto
	idivq	%rcx
	testq	%rdx, %rdx
	jne	.L32
	jmp	.L9
.L13:
	movl	$1, %edx
	jmp	.L2
.L30:
	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
```assembly
	.file	"temp.c"
	.text
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%lld"
.LC1:
	.string	"%lld\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB39:
	.cfi_startproc
	endbr64
	subq	$24, %rsp
	.cfi_def_cfa_offset 32
	leaq	.LC0(%rip), %rdi
	movq	%fs:40, %rax
	movq	%rax, 8(%rsp)
	xorl	%eax, %eax
	movq	%rsp, %rsi
	call	__isoc99_scanf@PLT
	movq	(%rsp), %rsi
	movl	$1, %ecx
	cmpq	$1, %rsi
	jle	.L13
	.p2align 4,,10
	.p2align 3
.L3:
	addq	%rcx, %rcx
	movq	%rcx, %rdx
	imulq	%rcx, %rdx
	cmpq	%rsi, %rdx
	jl	.L3
.L2:
	leaq	-1(%rcx), %rax
	movq	%rsi, %rdi
	subq	%rsi, %rdx
	movq	%rax, %r8
	imulq	%rax, %r8
	subq	%r8, %rdi
	cmpq	%rdi, %rdx
	jg	.L4
	movq	%rcx, %rdx
	imulq	%rcx, %rdx
	cmpq	%rsi, %rdx
	jg	.L5
	jmp	.L6
	.p2align 4,,10
	.p2align 3
.L29:
	subq	$1, %rcx
.L6:
	movq	%rsi, %rax
	cqto
	idivq	%rcx
	testq	%rdx, %rdx
	jne	.L29
.L9:
	movq	%rsi, %rax
	movl	$1, %edi
	leaq	.LC1(%rip), %rsi
	cqto
	idivq	%rcx
	leaq	-2(%rcx,%rax), %rdx
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	stdout(%rip), %rdi
	call	fflush@PLT
	movq	8(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L30
	xorl	%eax, %eax
	addq	$24, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L31:
	.cfi_restore_state
	subq	$1, %rax
.L5:
	movq	%rax, %rdx
	movq	%rax, %rcx
	imulq	%rax, %rdx
	cmpq	%rsi, %rdx
	jg	.L31
	jmp	.L6
.L4:
	sarq	%rcx
	movq	%rcx, %rax
	imulq	%rcx, %rax
	cmpq	%rsi, %rax
	jge	.L7
.L8:
	addq	$1, %rcx
	movq	%rcx, %rax
	imulq	%rcx, %rax
	cmpq	%rsi, %rax
	jge	.L7
	addq	$1, %rcx
	movq	%rcx, %rax
	imulq	%rcx, %rax
	cmpq	%rsi, %rax
	jl	.L8
	jmp	.L7
	.p2align 4,,10
	.p2align 3
.L32:
	subq	$1, %rcx
.L7:
	movq	%rsi, %rax
	cqto
	idivq	%rcx
	testq	%rdx, %rdx
	jne	.L32
	jmp	.L9
.L13:
	movl	$1, %edx
	jmp	.L2
.L30:
	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:
```
```c
#include <stdio.h>
#include <stdlib.h>

int main()
{
	long long N;
	scanf("%lld", &N);
	
	long long n;
	for (n = 1; n * n < N; n *= 2);
	if (n * n - N > N - (n-1) * (n-1)) {
		for (n /= 2; n * n < N; n++);
		for (; N % n != 0; n--);
	} else {
		for (; n * n > N; n--);
		for (; N % n != 0; n--);
	}	
	
	printf("%lld\n", n + N / n - 2);
	fflush(stdout);
	return 0;
}```
Given the following C code, your task is to generate highly optimized x86-64 assembly code.
C Code:

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

int main()
{
	long long N;
	scanf("%lld", &N);
	
	long long n;
	for (n = 1; n * n < N; n *= 2);
	if (n * n - N > N - (n-1) * (n-1)) {
		for (n /= 2; n * n < N; n++);
		for (; N % n != 0; n--);
	} else {
		for (; n * n > N; n--);
		for (; N % n != 0; n--);
	}	
	
	printf("%lld\n", n + N / n - 2);
	fflush(stdout);
	return 0;
}```

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.
Optimized Assembly Code:

6069423871
 83
 19
 605667865
 72
 33
 927082247
 40
 5
 223605823

23434326
 82
 18
 82100
 15
 12
 61750
 11
 4
 31934

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

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

int main()
{
	long long N;
	scanf("%lld", &N);
	
	long long n;
	for (n = 1; n * n < N; n *= 2);
	if (n * n - N > N - (n-1) * (n-1)) {
		for (n /= 2; n * n < N; n++);
		for (; N % n != 0; n--);
	} else {
		for (; n * n > N; n--);
		for (; N % n != 0; n--);
	}	
	
	printf("%lld\n", n + N / n - 2);
	fflush(stdout);
	return 0;
}```

Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%lld"
.LC1:
	.string	"%lld\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB39:
	.cfi_startproc
	endbr64
	subq	$24, %rsp
	.cfi_def_cfa_offset 32
	leaq	.LC0(%rip), %rdi
	movq	%fs:40, %rax
	movq	%rax, 8(%rsp)
	xorl	%eax, %eax
	movq	%rsp, %rsi
	call	__isoc99_scanf@PLT
	movq	(%rsp), %rsi
	movl	$1, %ecx
	cmpq	$1, %rsi
	jle	.L13
	.p2align 4,,10
	.p2align 3
.L3:
	addq	%rcx, %rcx
	movq	%rcx, %rdx
	imulq	%rcx, %rdx
	cmpq	%rsi, %rdx
	jl	.L3
.L2:
	leaq	-1(%rcx), %rax
	movq	%rsi, %rdi
	subq	%rsi, %rdx
	movq	%rax, %r8
	imulq	%rax, %r8
	subq	%r8, %rdi
	cmpq	%rdi, %rdx
	jg	.L4
	movq	%rcx, %rdx
	imulq	%rcx, %rdx
	cmpq	%rsi, %rdx
	jg	.L5
	jmp	.L6
	.p2align 4,,10
	.p2align 3
.L29:
	subq	$1, %rcx
.L6:
	movq	%rsi, %rax
	cqto
	idivq	%rcx
	testq	%rdx, %rdx
	jne	.L29
.L9:
	movq	%rsi, %rax
	movl	$1, %edi
	leaq	.LC1(%rip), %rsi
	cqto
	idivq	%rcx
	leaq	-2(%rcx,%rax), %rdx
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	stdout(%rip), %rdi
	call	fflush@PLT
	movq	8(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L30
	xorl	%eax, %eax
	addq	$24, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L31:
	.cfi_restore_state
	subq	$1, %rax
.L5:
	movq	%rax, %rdx
	movq	%rax, %rcx
	imulq	%rax, %rdx
	cmpq	%rsi, %rdx
	jg	.L31
	jmp	.L6
.L4:
	sarq	%rcx
	movq	%rcx, %rax
	imulq	%rcx, %rax
	cmpq	%rsi, %rax
	jge	.L7
.L8:
	addq	$1, %rcx
	movq	%rcx, %rax
	imulq	%rcx, %rax
	cmpq	%rsi, %rax
	jge	.L7
	addq	$1, %rcx
	movq	%rcx, %rax
	imulq	%rcx, %rax
	cmpq	%rsi, %rax
	jl	.L8
	jmp	.L7
	.p2align 4,,10
	.p2align 3
.L32:
	subq	$1, %rcx
.L7:
	movq	%rsi, %rax
	cqto
	idivq	%rcx
	testq	%rdx, %rdx
	jne	.L32
	jmp	.L9
.L13:
	movl	$1, %edx
	jmp	.L2
.L30:
	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:
```

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.
Optimized Assembly Code:

train
```assembly
	.file	"temp.c"
	.text
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%lld"
.LC1:
	.string	"%lld\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB39:
	.cfi_startproc
	endbr64
	subq	$24, %rsp
	.cfi_def_cfa_offset 32
	leaq	.LC0(%rip), %rdi
	movq	%fs:40, %rax
	movq	%rax, 8(%rsp)
	xorl	%eax, %eax
	movq	%rsp, %rsi
	call	__isoc99_scanf@PLT
	movq	(%rsp), %rsi
	movl	$1, %ecx
	cmpq	$1, %rsi
	jle	.L13
	.p2align 4,,10
	.p2align 3
.L3:
	addq	%rcx, %rcx
	movq	%rcx, %rdx
	imulq	%rcx, %rdx
	cmpq	%rsi, %rdx
	jl	.L3
.L2:
	leaq	-1(%rcx), %rax
	movq	%rsi, %rdi
	subq	%rsi, %rdx
	movq	%rax, %r8
	imulq	%rax, %r8
	subq	%r8, %rdi
	cmpq	%rdi, %rdx
	jg	.L4
	movq	%rcx, %rdx
	imulq	%rcx, %rdx
	cmpq	%rsi, %rdx
	jg	.L5
	jmp	.L6
	.p2align 4,,10
	.p2align 3
.L29:
	subq	$1, %rcx
.L6:
	movq	%rsi, %rax
	cqto
	idivq	%rcx
	testq	%rdx, %rdx
	jne	.L29
.L9:
	movq	%rsi, %rax
	movl	$1, %edi
	leaq	.LC1(%rip), %rsi
	cqto
	idivq	%rcx
	leaq	-2(%rcx,%rax), %rdx
	xorl	%eax, %eax
	call	__printf_chk@PLT
	movq	stdout(%rip), %rdi
	call	fflush@PLT
	movq	8(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L30
	xorl	%eax, %eax
	addq	$24, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L31:
	.cfi_restore_state
	subq	$1, %rax
.L5:
	movq	%rax, %rdx
	movq	%rax, %rcx
	imulq	%rax, %rdx
	cmpq	%rsi, %rdx
	jg	.L31
	jmp	.L6
.L4:
	sarq	%rcx
	movq	%rcx, %rax
	imulq	%rcx, %rax
	cmpq	%rsi, %rax
	jge	.L7
.L8:
	addq	$1, %rcx
	movq	%rcx, %rax
	imulq	%rcx, %rax
	cmpq	%rsi, %rax
	jge	.L7
	addq	$1, %rcx
	movq	%rcx, %rax
	imulq	%rcx, %rax
	cmpq	%rsi, %rax
	jl	.L8
	jmp	.L7
	.p2align 4,,10
	.p2align 3
.L32:
	subq	$1, %rcx
.L7:
	movq	%rsi, %rax
	cqto
	idivq	%rcx
	testq	%rdx, %rdx
	jne	.L32
	jmp	.L9
.L13:
	movl	$1, %edx
	jmp	.L2
.L30:
	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:
```