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<stdint.h>
#include<inttypes.h>

typedef int32_t i32;
typedef int64_t i64;

void run (void) {
  i32 n, k;
  scanf ("%" SCNi32 "%" SCNi32, &n, &k);
  i64 l = 0;
  i64 r = 1000000000000000000LL + 1;
  while (r - l > 1) {
    i64 m = (l + r) / 2;
    for (i32 i = 0; i < n && m >= 0; ++i) {
      m--;
      m -= m / k;
    }
    if (m < 0) {
      l = (l + r) / 2;
    } else {
      r = (l + r) / 2;
    }
  }
  printf ("%" PRIi64 "\n", l);
}

int main (void) {
  run();
  return 0;
}
```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%i%i"
.LC1:
	.string	"%li\n"
	.text
	.globl	run
	.type	run, @function
run:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$48, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-40(%rbp), %rdx
	leaq	-44(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movq	$0, -32(%rbp)
	movabsq	$1000000000000000001, %rax
	movq	%rax, -24(%rbp)
	jmp	.L2
.L7:
	movq	-32(%rbp), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movq	%rax, %rdx
	shrq	$63, %rdx
	addq	%rdx, %rax
	sarq	%rax
	movq	%rax, -16(%rbp)
	movl	$0, -36(%rbp)
	jmp	.L3
.L5:
	subq	$1, -16(%rbp)
	movl	-40(%rbp), %eax
	movslq	%eax, %rcx
	movq	-16(%rbp), %rax
	cqto
	idivq	%rcx
	subq	%rax, -16(%rbp)
	addl	$1, -36(%rbp)
.L3:
	movl	-44(%rbp), %eax
	cmpl	%eax, -36(%rbp)
	jge	.L4
	cmpq	$0, -16(%rbp)
	jns	.L5
.L4:
	cmpq	$0, -16(%rbp)
	jns	.L6
	movq	-32(%rbp), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movq	%rax, %rdx
	shrq	$63, %rdx
	addq	%rdx, %rax
	sarq	%rax
	movq	%rax, -32(%rbp)
	jmp	.L2
.L6:
	movq	-32(%rbp), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movq	%rax, %rdx
	shrq	$63, %rdx
	addq	%rdx, %rax
	sarq	%rax
	movq	%rax, -24(%rbp)
.L2:
	movq	-24(%rbp), %rax
	subq	-32(%rbp), %rax
	cmpq	$1, %rax
	jg	.L7
	movq	-32(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	nop
	movq	-8(%rbp), %rax
	subq	%fs:40, %rax
	je	.L8
	call	__stack_chk_fail@PLT
.L8:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	run, .-run
	.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
	call	run
	movl	$0, %eax
	popq	%rbp
	.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
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%i%i"
.LC1:
	.string	"%li\n"
	.text
	.p2align 4
	.globl	run
	.type	run, @function
run:
.LFB23:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	leaq	.LC0(%rip), %rdi
	subq	$16, %rsp
	.cfi_def_cfa_offset 32
	movq	%fs:40, %rax
	movq	%rax, 8(%rsp)
	xorl	%eax, %eax
	leaq	4(%rsp), %rdx
	movq	%rsp, %rsi
	call	__isoc99_scanf@PLT
	movl	(%rsp), %r8d
	movslq	4(%rsp), %rdi
	xorl	%r10d, %r10d
	movabsq	$1000000000000000001, %r11
	.p2align 4,,10
	.p2align 3
.L2:
	leaq	(%r11,%r10), %rax
	movq	%rax, %r9
	shrq	$63, %r9
	addq	%rax, %r9
	sarq	%r9
	movq	%r9, %r12
	testl	%r8d, %r8d
	jle	.L9
	cmpq	$-1, %rax
	jl	.L4
	movq	%r9, %rcx
	xorl	%esi, %esi
	jmp	.L5
	.p2align 4,,10
	.p2align 3
.L14:
	testq	%rcx, %rcx
	js	.L4
.L5:
	subq	$1, %rcx
	addl	$1, %esi
	movq	%rcx, %rax
	cqto
	idivq	%rdi
	subq	%rax, %rcx
	cmpl	%r8d, %esi
	jne	.L14
	testq	%rcx, %rcx
	jns	.L15
.L4:
	movq	%r11, %rax
	subq	%r9, %rax
	cmpq	$1, %rax
	jle	.L7
.L6:
	movq	%r12, %r10
	jmp	.L2
.L17:
	movq	%r10, %r12
.L7:
	xorl	%eax, %eax
	movq	%r12, %rdx
	movl	$1, %edi
	leaq	.LC1(%rip), %rsi
	call	__printf_chk@PLT
	movq	8(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L16
	addq	$16, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
.L9:
	.cfi_restore_state
	movq	%r9, %rcx
	testq	%rcx, %rcx
	js	.L4
.L15:
	movq	%r9, %rax
	subq	%r10, %rax
	cmpq	$1, %rax
	jle	.L17
	movq	%r9, %r11
	movq	%r10, %r12
	jmp	.L6
.L16:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE23:
	.size	run, .-run
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB24:
	.cfi_startproc
	endbr64
	subq	$8, %rsp
	.cfi_def_cfa_offset 16
	call	run
	xorl	%eax, %eax
	addq	$8, %rsp
	.cfi_def_cfa_offset 8
	ret
	.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
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%i%i"
.LC1:
	.string	"%li\n"
	.text
	.p2align 4
	.globl	run
	.type	run, @function
run:
.LFB23:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	leaq	.LC0(%rip), %rdi
	subq	$16, %rsp
	.cfi_def_cfa_offset 32
	movq	%fs:40, %rax
	movq	%rax, 8(%rsp)
	xorl	%eax, %eax
	leaq	4(%rsp), %rdx
	movq	%rsp, %rsi
	call	__isoc99_scanf@PLT
	movl	(%rsp), %r8d
	movslq	4(%rsp), %rdi
	xorl	%r10d, %r10d
	movabsq	$1000000000000000001, %r11
	.p2align 4,,10
	.p2align 3
.L2:
	leaq	(%r11,%r10), %rax
	movq	%rax, %r9
	shrq	$63, %r9
	addq	%rax, %r9
	sarq	%r9
	movq	%r9, %r12
	testl	%r8d, %r8d
	jle	.L9
	cmpq	$-1, %rax
	jl	.L4
	movq	%r9, %rcx
	xorl	%esi, %esi
	jmp	.L5
	.p2align 4,,10
	.p2align 3
.L14:
	testq	%rcx, %rcx
	js	.L4
.L5:
	subq	$1, %rcx
	addl	$1, %esi
	movq	%rcx, %rax
	cqto
	idivq	%rdi
	subq	%rax, %rcx
	cmpl	%r8d, %esi
	jne	.L14
	testq	%rcx, %rcx
	jns	.L15
.L4:
	movq	%r11, %rax
	subq	%r9, %rax
	cmpq	$1, %rax
	jle	.L7
.L6:
	movq	%r12, %r10
	jmp	.L2
.L17:
	movq	%r10, %r12
.L7:
	xorl	%eax, %eax
	movq	%r12, %rdx
	movl	$1, %edi
	leaq	.LC1(%rip), %rsi
	call	__printf_chk@PLT
	movq	8(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L16
	addq	$16, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
.L9:
	.cfi_restore_state
	movq	%r9, %rcx
	testq	%rcx, %rcx
	js	.L4
.L15:
	movq	%r9, %rax
	subq	%r10, %rax
	cmpq	$1, %rax
	jle	.L17
	movq	%r9, %r11
	movq	%r10, %r12
	jmp	.L6
.L16:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE23:
	.size	run, .-run
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB24:
	.cfi_startproc
	endbr64
	subq	$8, %rsp
	.cfi_def_cfa_offset 16
	call	run
	xorl	%eax, %eax
	addq	$8, %rsp
	.cfi_def_cfa_offset 8
	ret
	.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<stdint.h>
#include<inttypes.h>

typedef int32_t i32;
typedef int64_t i64;

void run (void) {
  i32 n, k;
  scanf ("%" SCNi32 "%" SCNi32, &n, &k);
  i64 l = 0;
  i64 r = 1000000000000000000LL + 1;
  while (r - l > 1) {
    i64 m = (l + r) / 2;
    for (i32 i = 0; i < n && m >= 0; ++i) {
      m--;
      m -= m / k;
    }
    if (m < 0) {
      l = (l + r) / 2;
    } else {
      r = (l + r) / 2;
    }
  }
  printf ("%" PRIi64 "\n", l);
}

int main (void) {
  run();
  return 0;
}

5 2
 7 2
 10 2
 2 2
 1 2
 4 3
 8 2
 6 2
 7 4
 3 3

15
 63
 511
 1
 0
 4
 127
 31
 10
 2

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<stdint.h>
#include<inttypes.h>

typedef int32_t i32;
typedef int64_t i64;

void run (void) {
  i32 n, k;
  scanf ("%" SCNi32 "%" SCNi32, &n, &k);
  i64 l = 0;
  i64 r = 1000000000000000000LL + 1;
  while (r - l > 1) {
    i64 m = (l + r) / 2;
    for (i32 i = 0; i < n && m >= 0; ++i) {
      m--;
      m -= m / k;
    }
    if (m < 0) {
      l = (l + r) / 2;
    } else {
      r = (l + r) / 2;
    }
  }
  printf ("%" PRIi64 "\n", l);
}

int main (void) {
  run();
  return 0;
}
```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%i%i"
.LC1:
	.string	"%li\n"
	.text
	.globl	run
	.type	run, @function
run:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$48, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-40(%rbp), %rdx
	leaq	-44(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movq	$0, -32(%rbp)
	movabsq	$1000000000000000001, %rax
	movq	%rax, -24(%rbp)
	jmp	.L2
.L7:
	movq	-32(%rbp), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movq	%rax, %rdx
	shrq	$63, %rdx
	addq	%rdx, %rax
	sarq	%rax
	movq	%rax, -16(%rbp)
	movl	$0, -36(%rbp)
	jmp	.L3
.L5:
	subq	$1, -16(%rbp)
	movl	-40(%rbp), %eax
	movslq	%eax, %rcx
	movq	-16(%rbp), %rax
	cqto
	idivq	%rcx
	subq	%rax, -16(%rbp)
	addl	$1, -36(%rbp)
.L3:
	movl	-44(%rbp), %eax
	cmpl	%eax, -36(%rbp)
	jge	.L4
	cmpq	$0, -16(%rbp)
	jns	.L5
.L4:
	cmpq	$0, -16(%rbp)
	jns	.L6
	movq	-32(%rbp), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movq	%rax, %rdx
	shrq	$63, %rdx
	addq	%rdx, %rax
	sarq	%rax
	movq	%rax, -32(%rbp)
	jmp	.L2
.L6:
	movq	-32(%rbp), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movq	%rax, %rdx
	shrq	$63, %rdx
	addq	%rdx, %rax
	sarq	%rax
	movq	%rax, -24(%rbp)
.L2:
	movq	-24(%rbp), %rax
	subq	-32(%rbp), %rax
	cmpq	$1, %rax
	jg	.L7
	movq	-32(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	nop
	movq	-8(%rbp), %rax
	subq	%fs:40, %rax
	je	.L8
	call	__stack_chk_fail@PLT
.L8:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	run, .-run
	.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
	call	run
	movl	$0, %eax
	popq	%rbp
	.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
	.section	.rodata
.LC0:
	.string	"%i%i"
.LC1:
	.string	"%li\n"
	.text
	.globl	run
	.type	run, @function
run:
.LFB0:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$48, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-40(%rbp), %rdx
	leaq	-44(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movq	$0, -32(%rbp)
	movabsq	$1000000000000000001, %rax
	movq	%rax, -24(%rbp)
	jmp	.L2
.L7:
	movq	-32(%rbp), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movq	%rax, %rdx
	shrq	$63, %rdx
	addq	%rdx, %rax
	sarq	%rax
	movq	%rax, -16(%rbp)
	movl	$0, -36(%rbp)
	jmp	.L3
.L5:
	subq	$1, -16(%rbp)
	movl	-40(%rbp), %eax
	movslq	%eax, %rcx
	movq	-16(%rbp), %rax
	cqto
	idivq	%rcx
	subq	%rax, -16(%rbp)
	addl	$1, -36(%rbp)
.L3:
	movl	-44(%rbp), %eax
	cmpl	%eax, -36(%rbp)
	jge	.L4
	cmpq	$0, -16(%rbp)
	jns	.L5
.L4:
	cmpq	$0, -16(%rbp)
	jns	.L6
	movq	-32(%rbp), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movq	%rax, %rdx
	shrq	$63, %rdx
	addq	%rdx, %rax
	sarq	%rax
	movq	%rax, -32(%rbp)
	jmp	.L2
.L6:
	movq	-32(%rbp), %rdx
	movq	-24(%rbp), %rax
	addq	%rdx, %rax
	movq	%rax, %rdx
	shrq	$63, %rdx
	addq	%rdx, %rax
	sarq	%rax
	movq	%rax, -24(%rbp)
.L2:
	movq	-24(%rbp), %rax
	subq	-32(%rbp), %rax
	cmpq	$1, %rax
	jg	.L7
	movq	-32(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	nop
	movq	-8(%rbp), %rax
	subq	%fs:40, %rax
	je	.L8
	call	__stack_chk_fail@PLT
.L8:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.size	run, .-run
	.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
	call	run
	movl	$0, %eax
	popq	%rbp
	.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:
