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<math.h>
long long int ketawa(long long int b, long long int n)
{
	long long int res = 0;
	while (n > 0)
	{
		res += n % b;
		n /= b;
	}
	return res;
}
int main()
{
	long long int n, s;
	scanf("%lld %lld", &n, &s);
	if (n < s)
	{
		printf("-1\n");
		return 0;
	}
	if (n == s)
	{
		printf("%lld\n", n + 1);
		return 0;
	}
	long long int i;
	for (i = 2; i <= (long long int)sqrt(n); i++)
	{
		if (ketawa(i, n) == s)
		{
			printf("%lld\n", i);
			return 0;
		}
	}
	long long int x, y, b;
	for (i = 1; i <= (long long int)sqrt(n - s); i++)
	{
		if ((n - s) % i == 0)
		{
			b = i + 1;
			x = (n - s) / i;
			y = s - x;
			if (x >= 0 && y >= 0 && b >= 0 && x < b && y < b)
			{
				printf("%lld\n", b);
				return 0;
			}
		}
	}
	for (i = (long long int)(sqrt(n - s)); i > 0; i--)
	{
		if ((n - s) % i == 0)
		{
			x = i;
			y = s - x;
			b = (n - y) / x;
			if (x >= 0 && y >= 0 && b >= 0 && x < b && y < b)
			{
				printf("%lld\n", b);
				return 0;
			}
		}
	}
	printf("-1\n");
	return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	ketawa
	.type	ketawa, @function
ketawa:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movq	%rdi, -24(%rbp)
	movq	%rsi, -32(%rbp)
	movq	$0, -8(%rbp)
	jmp	.L2
.L3:
	movq	-32(%rbp), %rax
	cqto
	idivq	-24(%rbp)
	movq	%rdx, %rax
	addq	%rax, -8(%rbp)
	movq	-32(%rbp), %rax
	cqto
	idivq	-24(%rbp)
	movq	%rax, -32(%rbp)
.L2:
	cmpq	$0, -32(%rbp)
	jg	.L3
	movq	-8(%rbp), %rax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	ketawa, .-ketawa
	.section	.rodata
.LC0:
	.string	"%lld %lld"
.LC1:
	.string	"-1"
.LC2:
	.string	"%lld\n"
	.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	$64, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-48(%rbp), %rdx
	leaq	-56(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movq	-56(%rbp), %rdx
	movq	-48(%rbp), %rax
	cmpq	%rax, %rdx
	jge	.L6
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	movl	$0, %eax
	jmp	.L18
.L6:
	movq	-56(%rbp), %rdx
	movq	-48(%rbp), %rax
	cmpq	%rax, %rdx
	jne	.L8
	movq	-56(%rbp), %rax
	addq	$1, %rax
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	jmp	.L18
.L8:
	movq	$2, -40(%rbp)
	jmp	.L9
.L11:
	movq	-56(%rbp), %rdx
	movq	-40(%rbp), %rax
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	ketawa
	movq	-48(%rbp), %rdx
	cmpq	%rdx, %rax
	jne	.L10
	movq	-40(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	jmp	.L18
.L10:
	addq	$1, -40(%rbp)
.L9:
	movq	-56(%rbp), %rax
	pxor	%xmm1, %xmm1
	cvtsi2sdq	%rax, %xmm1
	movq	%xmm1, %rax
	movq	%rax, %xmm0
	call	sqrt@PLT
	cvttsd2siq	%xmm0, %rax
	cmpq	%rax, -40(%rbp)
	jle	.L11
	movq	$1, -40(%rbp)
	jmp	.L12
.L14:
	movq	-56(%rbp), %rax
	movq	-48(%rbp), %rdx
	subq	%rdx, %rax
	cqto
	idivq	-40(%rbp)
	movq	%rdx, %rax
	testq	%rax, %rax
	jne	.L13
	movq	-40(%rbp), %rax
	addq	$1, %rax
	movq	%rax, -16(%rbp)
	movq	-56(%rbp), %rax
	movq	-48(%rbp), %rdx
	subq	%rdx, %rax
	cqto
	idivq	-40(%rbp)
	movq	%rax, -32(%rbp)
	movq	-48(%rbp), %rax
	subq	-32(%rbp), %rax
	movq	%rax, -24(%rbp)
	cmpq	$0, -32(%rbp)
	js	.L13
	cmpq	$0, -24(%rbp)
	js	.L13
	cmpq	$0, -16(%rbp)
	js	.L13
	movq	-32(%rbp), %rax
	cmpq	-16(%rbp), %rax
	jge	.L13
	movq	-24(%rbp), %rax
	cmpq	-16(%rbp), %rax
	jge	.L13
	movq	-16(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	jmp	.L18
.L13:
	addq	$1, -40(%rbp)
.L12:
	movq	-56(%rbp), %rax
	movq	-48(%rbp), %rdx
	subq	%rdx, %rax
	pxor	%xmm2, %xmm2
	cvtsi2sdq	%rax, %xmm2
	movq	%xmm2, %rax
	movq	%rax, %xmm0
	call	sqrt@PLT
	cvttsd2siq	%xmm0, %rax
	cmpq	%rax, -40(%rbp)
	jle	.L14
	movq	-56(%rbp), %rax
	movq	-48(%rbp), %rdx
	subq	%rdx, %rax
	pxor	%xmm3, %xmm3
	cvtsi2sdq	%rax, %xmm3
	movq	%xmm3, %rax
	movq	%rax, %xmm0
	call	sqrt@PLT
	cvttsd2siq	%xmm0, %rax
	movq	%rax, -40(%rbp)
	jmp	.L15
.L17:
	movq	-56(%rbp), %rax
	movq	-48(%rbp), %rdx
	subq	%rdx, %rax
	cqto
	idivq	-40(%rbp)
	movq	%rdx, %rax
	testq	%rax, %rax
	jne	.L16
	movq	-40(%rbp), %rax
	movq	%rax, -32(%rbp)
	movq	-48(%rbp), %rax
	subq	-32(%rbp), %rax
	movq	%rax, -24(%rbp)
	movq	-56(%rbp), %rax
	subq	-24(%rbp), %rax
	cqto
	idivq	-32(%rbp)
	movq	%rax, -16(%rbp)
	cmpq	$0, -32(%rbp)
	js	.L16
	cmpq	$0, -24(%rbp)
	js	.L16
	cmpq	$0, -16(%rbp)
	js	.L16
	movq	-32(%rbp), %rax
	cmpq	-16(%rbp), %rax
	jge	.L16
	movq	-24(%rbp), %rax
	cmpq	-16(%rbp), %rax
	jge	.L16
	movq	-16(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	jmp	.L18
.L16:
	subq	$1, -40(%rbp)
.L15:
	cmpq	$0, -40(%rbp)
	jg	.L17
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	movl	$0, %eax
.L18:
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L19
	call	__stack_chk_fail@PLT
.L19:
	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	ketawa
	.type	ketawa, @function
ketawa:
.LFB23:
	.cfi_startproc
	endbr64
	movq	%rsi, %rax
	xorl	%r8d, %r8d
	testq	%rsi, %rsi
	jle	.L1
	.p2align 4,,10
	.p2align 3
.L3:
	cqto
	idivq	%rdi
	addq	%rdx, %r8
	testq	%rax, %rax
	jg	.L3
.L1:
	movq	%r8, %rax
	ret
	.cfi_endproc
.LFE23:
	.size	ketawa, .-ketawa
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%lld %lld"
.LC1:
	.string	"-1"
.LC2:
	.string	"%lld\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB24:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	leaq	.LC0(%rip), %rdi
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	subq	$56, %rsp
	.cfi_def_cfa_offset 96
	movq	%fs:40, %rax
	movq	%rax, 40(%rsp)
	xorl	%eax, %eax
	leaq	32(%rsp), %rdx
	leaq	24(%rsp), %rsi
	call	__isoc99_scanf@PLT
	movq	24(%rsp), %rbp
	movq	32(%rsp), %r13
	cmpq	%r13, %rbp
	jl	.L26
	je	.L10
	pxor	%xmm1, %xmm1
	movl	$2, %r12d
	pxor	%xmm2, %xmm2
	cvtsi2sdq	%rbp, %xmm1
	.p2align 4,,10
	.p2align 3
.L11:
	ucomisd	%xmm1, %xmm2
	movapd	%xmm1, %xmm0
	ja	.L53
	sqrtsd	%xmm0, %xmm0
.L16:
	cvttsd2siq	%xmm0, %rax
	cmpq	%r12, %rax
	jl	.L56
	movq	%rbp, %rax
	xorl	%ecx, %ecx
	testq	%rbp, %rbp
	jle	.L24
	.p2align 4,,10
	.p2align 3
.L12:
	cqto
	idivq	%r12
	addq	%rdx, %rcx
	testq	%rax, %rax
	jne	.L12
.L24:
	cmpq	%rcx, %r13
	je	.L22
	addq	$1, %r12
	jmp	.L11
.L21:
	movapd	%xmm1, %xmm0
	call	sqrt@PLT
	cvttsd2siq	%xmm0, %rcx
	testq	%rcx, %rcx
	jle	.L26
	movq	%r13, %rsi
	subq	%r13, %rbp
	subq	%rcx, %rsi
	.p2align 4,,10
	.p2align 3
.L28:
	movq	%rbx, %rax
	cqto
	idivq	%rcx
	testq	%rdx, %rdx
	jne	.L27
	testq	%rsi, %rsi
	js	.L27
	leaq	0(%rbp,%rcx), %rax
	cqto
	idivq	%rcx
	movq	%rax, %rdx
	notq	%rdx
	shrq	$63, %rdx
	cmpq	%rax, %rcx
	setl	%dil
	testb	%dl, %dil
	je	.L27
	cmpq	%rsi, %rax
	jg	.L57
	.p2align 4,,10
	.p2align 3
.L27:
	addq	$1, %rsi
	subq	$1, %rcx
	jne	.L28
.L26:
	leaq	.LC1(%rip), %rdi
	call	puts@PLT
.L9:
	movq	40(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L58
	addq	$56, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 40
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%rbp
	.cfi_def_cfa_offset 24
	popq	%r12
	.cfi_def_cfa_offset 16
	popq	%r13
	.cfi_def_cfa_offset 8
	ret
.L56:
	.cfi_restore_state
	movq	%rbp, %rbx
	pxor	%xmm1, %xmm1
	subq	%r13, %rbx
	cvtsi2sdq	%rbx, %xmm1
	ucomisd	%xmm1, %xmm2
	ja	.L54
	sqrtsd	%xmm1, %xmm0
	movl	$1, %r12d
	cvttsd2siq	%xmm0, %rcx
	.p2align 4,,10
	.p2align 3
.L47:
	cmpq	%r12, %rcx
	jl	.L21
	movq	%rbx, %rax
	cqto
	idivq	%r12
	addq	$1, %r12
	testq	%rdx, %rdx
	jne	.L47
	movq	%r13, %rdx
	subq	%rax, %rdx
	cmpq	%r12, %rdx
	jnb	.L47
	cmpq	%r12, %rax
	jge	.L47
.L22:
	movq	%r12, %rdx
	leaq	.LC2(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L9
.L10:
	leaq	1(%rbp), %rdx
	leaq	.LC2(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L9
.L57:
	movq	%rax, %rdx
	leaq	.LC2(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L9
.L53:
	movsd	%xmm1, 8(%rsp)
	call	sqrt@PLT
	movsd	8(%rsp), %xmm1
	pxor	%xmm2, %xmm2
	jmp	.L16
.L58:
	call	__stack_chk_fail@PLT
.L54:
	movl	$1, %r12d
.L46:
	movapd	%xmm1, %xmm0
	movsd	%xmm1, 8(%rsp)
	call	sqrt@PLT
	movsd	8(%rsp), %xmm1
	cvttsd2siq	%xmm0, %rax
	cmpq	%r12, %rax
	jl	.L21
	movq	%rbx, %rax
	cqto
	idivq	%r12
	addq	$1, %r12
	testq	%rdx, %rdx
	jne	.L46
	movq	%r13, %rdx
	subq	%rax, %rdx
	cmpq	%r12, %rdx
	jnb	.L46
	cmpq	%r12, %rax
	jge	.L46
	jmp	.L22
	.cfi_endproc
.LFE24:
	.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
	.p2align 4
	.globl	ketawa
	.type	ketawa, @function
ketawa:
.LFB23:
	.cfi_startproc
	endbr64
	movq	%rsi, %rax
	xorl	%r8d, %r8d
	testq	%rsi, %rsi
	jle	.L1
	.p2align 4,,10
	.p2align 3
.L3:
	cqto
	idivq	%rdi
	addq	%rdx, %r8
	testq	%rax, %rax
	jg	.L3
.L1:
	movq	%r8, %rax
	ret
	.cfi_endproc
.LFE23:
	.size	ketawa, .-ketawa
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%lld %lld"
.LC1:
	.string	"-1"
.LC2:
	.string	"%lld\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB24:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	leaq	.LC0(%rip), %rdi
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	subq	$56, %rsp
	.cfi_def_cfa_offset 96
	movq	%fs:40, %rax
	movq	%rax, 40(%rsp)
	xorl	%eax, %eax
	leaq	32(%rsp), %rdx
	leaq	24(%rsp), %rsi
	call	__isoc99_scanf@PLT
	movq	24(%rsp), %rbp
	movq	32(%rsp), %r13
	cmpq	%r13, %rbp
	jl	.L26
	je	.L10
	pxor	%xmm1, %xmm1
	movl	$2, %r12d
	pxor	%xmm2, %xmm2
	cvtsi2sdq	%rbp, %xmm1
	.p2align 4,,10
	.p2align 3
.L11:
	ucomisd	%xmm1, %xmm2
	movapd	%xmm1, %xmm0
	ja	.L53
	sqrtsd	%xmm0, %xmm0
.L16:
	cvttsd2siq	%xmm0, %rax
	cmpq	%r12, %rax
	jl	.L56
	movq	%rbp, %rax
	xorl	%ecx, %ecx
	testq	%rbp, %rbp
	jle	.L24
	.p2align 4,,10
	.p2align 3
.L12:
	cqto
	idivq	%r12
	addq	%rdx, %rcx
	testq	%rax, %rax
	jne	.L12
.L24:
	cmpq	%rcx, %r13
	je	.L22
	addq	$1, %r12
	jmp	.L11
.L21:
	movapd	%xmm1, %xmm0
	call	sqrt@PLT
	cvttsd2siq	%xmm0, %rcx
	testq	%rcx, %rcx
	jle	.L26
	movq	%r13, %rsi
	subq	%r13, %rbp
	subq	%rcx, %rsi
	.p2align 4,,10
	.p2align 3
.L28:
	movq	%rbx, %rax
	cqto
	idivq	%rcx
	testq	%rdx, %rdx
	jne	.L27
	testq	%rsi, %rsi
	js	.L27
	leaq	0(%rbp,%rcx), %rax
	cqto
	idivq	%rcx
	movq	%rax, %rdx
	notq	%rdx
	shrq	$63, %rdx
	cmpq	%rax, %rcx
	setl	%dil
	testb	%dl, %dil
	je	.L27
	cmpq	%rsi, %rax
	jg	.L57
	.p2align 4,,10
	.p2align 3
.L27:
	addq	$1, %rsi
	subq	$1, %rcx
	jne	.L28
.L26:
	leaq	.LC1(%rip), %rdi
	call	puts@PLT
.L9:
	movq	40(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L58
	addq	$56, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 40
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%rbp
	.cfi_def_cfa_offset 24
	popq	%r12
	.cfi_def_cfa_offset 16
	popq	%r13
	.cfi_def_cfa_offset 8
	ret
.L56:
	.cfi_restore_state
	movq	%rbp, %rbx
	pxor	%xmm1, %xmm1
	subq	%r13, %rbx
	cvtsi2sdq	%rbx, %xmm1
	ucomisd	%xmm1, %xmm2
	ja	.L54
	sqrtsd	%xmm1, %xmm0
	movl	$1, %r12d
	cvttsd2siq	%xmm0, %rcx
	.p2align 4,,10
	.p2align 3
.L47:
	cmpq	%r12, %rcx
	jl	.L21
	movq	%rbx, %rax
	cqto
	idivq	%r12
	addq	$1, %r12
	testq	%rdx, %rdx
	jne	.L47
	movq	%r13, %rdx
	subq	%rax, %rdx
	cmpq	%r12, %rdx
	jnb	.L47
	cmpq	%r12, %rax
	jge	.L47
.L22:
	movq	%r12, %rdx
	leaq	.LC2(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L9
.L10:
	leaq	1(%rbp), %rdx
	leaq	.LC2(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L9
.L57:
	movq	%rax, %rdx
	leaq	.LC2(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L9
.L53:
	movsd	%xmm1, 8(%rsp)
	call	sqrt@PLT
	movsd	8(%rsp), %xmm1
	pxor	%xmm2, %xmm2
	jmp	.L16
.L58:
	call	__stack_chk_fail@PLT
.L54:
	movl	$1, %r12d
.L46:
	movapd	%xmm1, %xmm0
	movsd	%xmm1, 8(%rsp)
	call	sqrt@PLT
	movsd	8(%rsp), %xmm1
	cvttsd2siq	%xmm0, %rax
	cmpq	%r12, %rax
	jl	.L21
	movq	%rbx, %rax
	cqto
	idivq	%r12
	addq	$1, %r12
	testq	%rdx, %rdx
	jne	.L46
	movq	%r13, %rdx
	subq	%rax, %rdx
	cmpq	%r12, %rdx
	jnb	.L46
	cmpq	%r12, %rax
	jge	.L46
	jmp	.L22
	.cfi_endproc
.LFE24:
	.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<math.h>
long long int ketawa(long long int b, long long int n)
{
	long long int res = 0;
	while (n > 0)
	{
		res += n % b;
		n /= b;
	}
	return res;
}
int main()
{
	long long int n, s;
	scanf("%lld %lld", &n, &s);
	if (n < s)
	{
		printf("-1\n");
		return 0;
	}
	if (n == s)
	{
		printf("%lld\n", n + 1);
		return 0;
	}
	long long int i;
	for (i = 2; i <= (long long int)sqrt(n); i++)
	{
		if (ketawa(i, n) == s)
		{
			printf("%lld\n", i);
			return 0;
		}
	}
	long long int x, y, b;
	for (i = 1; i <= (long long int)sqrt(n - s); i++)
	{
		if ((n - s) % i == 0)
		{
			b = i + 1;
			x = (n - s) / i;
			y = s - x;
			if (x >= 0 && y >= 0 && b >= 0 && x < b && y < b)
			{
				printf("%lld\n", b);
				return 0;
			}
		}
	}
	for (i = (long long int)(sqrt(n - s)); i > 0; i--)
	{
		if ((n - s) % i == 0)
		{
			x = i;
			y = s - x;
			b = (n - y) / x;
			if (x >= 0 && y >= 0 && b >= 0 && x < b && y < b)
			{
				printf("%lld\n", b);
				return 0;
			}
		}
	}
	printf("-1\n");
	return 0;
}
87654
30

10

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<math.h>
long long int ketawa(long long int b, long long int n)
{
	long long int res = 0;
	while (n > 0)
	{
		res += n % b;
		n /= b;
	}
	return res;
}
int main()
{
	long long int n, s;
	scanf("%lld %lld", &n, &s);
	if (n < s)
	{
		printf("-1\n");
		return 0;
	}
	if (n == s)
	{
		printf("%lld\n", n + 1);
		return 0;
	}
	long long int i;
	for (i = 2; i <= (long long int)sqrt(n); i++)
	{
		if (ketawa(i, n) == s)
		{
			printf("%lld\n", i);
			return 0;
		}
	}
	long long int x, y, b;
	for (i = 1; i <= (long long int)sqrt(n - s); i++)
	{
		if ((n - s) % i == 0)
		{
			b = i + 1;
			x = (n - s) / i;
			y = s - x;
			if (x >= 0 && y >= 0 && b >= 0 && x < b && y < b)
			{
				printf("%lld\n", b);
				return 0;
			}
		}
	}
	for (i = (long long int)(sqrt(n - s)); i > 0; i--)
	{
		if ((n - s) % i == 0)
		{
			x = i;
			y = s - x;
			b = (n - y) / x;
			if (x >= 0 && y >= 0 && b >= 0 && x < b && y < b)
			{
				printf("%lld\n", b);
				return 0;
			}
		}
	}
	printf("-1\n");
	return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	ketawa
	.type	ketawa, @function
ketawa:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movq	%rdi, -24(%rbp)
	movq	%rsi, -32(%rbp)
	movq	$0, -8(%rbp)
	jmp	.L2
.L3:
	movq	-32(%rbp), %rax
	cqto
	idivq	-24(%rbp)
	movq	%rdx, %rax
	addq	%rax, -8(%rbp)
	movq	-32(%rbp), %rax
	cqto
	idivq	-24(%rbp)
	movq	%rax, -32(%rbp)
.L2:
	cmpq	$0, -32(%rbp)
	jg	.L3
	movq	-8(%rbp), %rax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	ketawa, .-ketawa
	.section	.rodata
.LC0:
	.string	"%lld %lld"
.LC1:
	.string	"-1"
.LC2:
	.string	"%lld\n"
	.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	$64, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-48(%rbp), %rdx
	leaq	-56(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movq	-56(%rbp), %rdx
	movq	-48(%rbp), %rax
	cmpq	%rax, %rdx
	jge	.L6
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	movl	$0, %eax
	jmp	.L18
.L6:
	movq	-56(%rbp), %rdx
	movq	-48(%rbp), %rax
	cmpq	%rax, %rdx
	jne	.L8
	movq	-56(%rbp), %rax
	addq	$1, %rax
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	jmp	.L18
.L8:
	movq	$2, -40(%rbp)
	jmp	.L9
.L11:
	movq	-56(%rbp), %rdx
	movq	-40(%rbp), %rax
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	ketawa
	movq	-48(%rbp), %rdx
	cmpq	%rdx, %rax
	jne	.L10
	movq	-40(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	jmp	.L18
.L10:
	addq	$1, -40(%rbp)
.L9:
	movq	-56(%rbp), %rax
	pxor	%xmm1, %xmm1
	cvtsi2sdq	%rax, %xmm1
	movq	%xmm1, %rax
	movq	%rax, %xmm0
	call	sqrt@PLT
	cvttsd2siq	%xmm0, %rax
	cmpq	%rax, -40(%rbp)
	jle	.L11
	movq	$1, -40(%rbp)
	jmp	.L12
.L14:
	movq	-56(%rbp), %rax
	movq	-48(%rbp), %rdx
	subq	%rdx, %rax
	cqto
	idivq	-40(%rbp)
	movq	%rdx, %rax
	testq	%rax, %rax
	jne	.L13
	movq	-40(%rbp), %rax
	addq	$1, %rax
	movq	%rax, -16(%rbp)
	movq	-56(%rbp), %rax
	movq	-48(%rbp), %rdx
	subq	%rdx, %rax
	cqto
	idivq	-40(%rbp)
	movq	%rax, -32(%rbp)
	movq	-48(%rbp), %rax
	subq	-32(%rbp), %rax
	movq	%rax, -24(%rbp)
	cmpq	$0, -32(%rbp)
	js	.L13
	cmpq	$0, -24(%rbp)
	js	.L13
	cmpq	$0, -16(%rbp)
	js	.L13
	movq	-32(%rbp), %rax
	cmpq	-16(%rbp), %rax
	jge	.L13
	movq	-24(%rbp), %rax
	cmpq	-16(%rbp), %rax
	jge	.L13
	movq	-16(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	jmp	.L18
.L13:
	addq	$1, -40(%rbp)
.L12:
	movq	-56(%rbp), %rax
	movq	-48(%rbp), %rdx
	subq	%rdx, %rax
	pxor	%xmm2, %xmm2
	cvtsi2sdq	%rax, %xmm2
	movq	%xmm2, %rax
	movq	%rax, %xmm0
	call	sqrt@PLT
	cvttsd2siq	%xmm0, %rax
	cmpq	%rax, -40(%rbp)
	jle	.L14
	movq	-56(%rbp), %rax
	movq	-48(%rbp), %rdx
	subq	%rdx, %rax
	pxor	%xmm3, %xmm3
	cvtsi2sdq	%rax, %xmm3
	movq	%xmm3, %rax
	movq	%rax, %xmm0
	call	sqrt@PLT
	cvttsd2siq	%xmm0, %rax
	movq	%rax, -40(%rbp)
	jmp	.L15
.L17:
	movq	-56(%rbp), %rax
	movq	-48(%rbp), %rdx
	subq	%rdx, %rax
	cqto
	idivq	-40(%rbp)
	movq	%rdx, %rax
	testq	%rax, %rax
	jne	.L16
	movq	-40(%rbp), %rax
	movq	%rax, -32(%rbp)
	movq	-48(%rbp), %rax
	subq	-32(%rbp), %rax
	movq	%rax, -24(%rbp)
	movq	-56(%rbp), %rax
	subq	-24(%rbp), %rax
	cqto
	idivq	-32(%rbp)
	movq	%rax, -16(%rbp)
	cmpq	$0, -32(%rbp)
	js	.L16
	cmpq	$0, -24(%rbp)
	js	.L16
	cmpq	$0, -16(%rbp)
	js	.L16
	movq	-32(%rbp), %rax
	cmpq	-16(%rbp), %rax
	jge	.L16
	movq	-24(%rbp), %rax
	cmpq	-16(%rbp), %rax
	jge	.L16
	movq	-16(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	jmp	.L18
.L16:
	subq	$1, -40(%rbp)
.L15:
	cmpq	$0, -40(%rbp)
	jg	.L17
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	movl	$0, %eax
.L18:
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L19
	call	__stack_chk_fail@PLT
.L19:
	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	ketawa
	.type	ketawa, @function
ketawa:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movq	%rdi, -24(%rbp)
	movq	%rsi, -32(%rbp)
	movq	$0, -8(%rbp)
	jmp	.L2
.L3:
	movq	-32(%rbp), %rax
	cqto
	idivq	-24(%rbp)
	movq	%rdx, %rax
	addq	%rax, -8(%rbp)
	movq	-32(%rbp), %rax
	cqto
	idivq	-24(%rbp)
	movq	%rax, -32(%rbp)
.L2:
	cmpq	$0, -32(%rbp)
	jg	.L3
	movq	-8(%rbp), %rax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	ketawa, .-ketawa
	.section	.rodata
.LC0:
	.string	"%lld %lld"
.LC1:
	.string	"-1"
.LC2:
	.string	"%lld\n"
	.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	$64, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-48(%rbp), %rdx
	leaq	-56(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movq	-56(%rbp), %rdx
	movq	-48(%rbp), %rax
	cmpq	%rax, %rdx
	jge	.L6
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	movl	$0, %eax
	jmp	.L18
.L6:
	movq	-56(%rbp), %rdx
	movq	-48(%rbp), %rax
	cmpq	%rax, %rdx
	jne	.L8
	movq	-56(%rbp), %rax
	addq	$1, %rax
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	jmp	.L18
.L8:
	movq	$2, -40(%rbp)
	jmp	.L9
.L11:
	movq	-56(%rbp), %rdx
	movq	-40(%rbp), %rax
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	ketawa
	movq	-48(%rbp), %rdx
	cmpq	%rdx, %rax
	jne	.L10
	movq	-40(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	jmp	.L18
.L10:
	addq	$1, -40(%rbp)
.L9:
	movq	-56(%rbp), %rax
	pxor	%xmm1, %xmm1
	cvtsi2sdq	%rax, %xmm1
	movq	%xmm1, %rax
	movq	%rax, %xmm0
	call	sqrt@PLT
	cvttsd2siq	%xmm0, %rax
	cmpq	%rax, -40(%rbp)
	jle	.L11
	movq	$1, -40(%rbp)
	jmp	.L12
.L14:
	movq	-56(%rbp), %rax
	movq	-48(%rbp), %rdx
	subq	%rdx, %rax
	cqto
	idivq	-40(%rbp)
	movq	%rdx, %rax
	testq	%rax, %rax
	jne	.L13
	movq	-40(%rbp), %rax
	addq	$1, %rax
	movq	%rax, -16(%rbp)
	movq	-56(%rbp), %rax
	movq	-48(%rbp), %rdx
	subq	%rdx, %rax
	cqto
	idivq	-40(%rbp)
	movq	%rax, -32(%rbp)
	movq	-48(%rbp), %rax
	subq	-32(%rbp), %rax
	movq	%rax, -24(%rbp)
	cmpq	$0, -32(%rbp)
	js	.L13
	cmpq	$0, -24(%rbp)
	js	.L13
	cmpq	$0, -16(%rbp)
	js	.L13
	movq	-32(%rbp), %rax
	cmpq	-16(%rbp), %rax
	jge	.L13
	movq	-24(%rbp), %rax
	cmpq	-16(%rbp), %rax
	jge	.L13
	movq	-16(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	jmp	.L18
.L13:
	addq	$1, -40(%rbp)
.L12:
	movq	-56(%rbp), %rax
	movq	-48(%rbp), %rdx
	subq	%rdx, %rax
	pxor	%xmm2, %xmm2
	cvtsi2sdq	%rax, %xmm2
	movq	%xmm2, %rax
	movq	%rax, %xmm0
	call	sqrt@PLT
	cvttsd2siq	%xmm0, %rax
	cmpq	%rax, -40(%rbp)
	jle	.L14
	movq	-56(%rbp), %rax
	movq	-48(%rbp), %rdx
	subq	%rdx, %rax
	pxor	%xmm3, %xmm3
	cvtsi2sdq	%rax, %xmm3
	movq	%xmm3, %rax
	movq	%rax, %xmm0
	call	sqrt@PLT
	cvttsd2siq	%xmm0, %rax
	movq	%rax, -40(%rbp)
	jmp	.L15
.L17:
	movq	-56(%rbp), %rax
	movq	-48(%rbp), %rdx
	subq	%rdx, %rax
	cqto
	idivq	-40(%rbp)
	movq	%rdx, %rax
	testq	%rax, %rax
	jne	.L16
	movq	-40(%rbp), %rax
	movq	%rax, -32(%rbp)
	movq	-48(%rbp), %rax
	subq	-32(%rbp), %rax
	movq	%rax, -24(%rbp)
	movq	-56(%rbp), %rax
	subq	-24(%rbp), %rax
	cqto
	idivq	-32(%rbp)
	movq	%rax, -16(%rbp)
	cmpq	$0, -32(%rbp)
	js	.L16
	cmpq	$0, -24(%rbp)
	js	.L16
	cmpq	$0, -16(%rbp)
	js	.L16
	movq	-32(%rbp), %rax
	cmpq	-16(%rbp), %rax
	jge	.L16
	movq	-24(%rbp), %rax
	cmpq	-16(%rbp), %rax
	jge	.L16
	movq	-16(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	jmp	.L18
.L16:
	subq	$1, -40(%rbp)
.L15:
	cmpq	$0, -40(%rbp)
	jg	.L17
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	movl	$0, %eax
.L18:
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L19
	call	__stack_chk_fail@PLT
.L19:
	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:
