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>

int main(void)
{
  unsigned long K, A, B, ANS;
  scanf("%ld %ld %ld", &K, &A, &B);
  //printf("K(%ld) A(%ld) B(%ld)\n", K, A, B);

  // 売れない
  if (K < ((A - 1) + 1)) {
    ANS = 1 + K;
  // 売れる
  } else {
    // 最初に叩いた残り回数が偶数の場合
    if ((K - (A - 1)) % 2 == 0) {
      // 売買で儲かる
      if (A + 2 < B) {
        ANS = 1 + (A - 1) + (B - A) * (K - (A - 1)) / 2;
      // 売買で儲からない
      } else {
        ANS = 1 + K;
      }
    // 最初に叩いた残り回数が奇数の場合
    } else {
      // 売買で儲かる
      if (A + 2 < B) {
        ANS = 1 + (A - 1) + (B - A) * (K - (A - 1) - 1) / 2 + 1;
      // 売買で儲からない
      } else {
        ANS = 1 + K;
      }
    }
  }
  printf("%ld\n", ANS);
  return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%ld %ld %ld"
.LC1:
	.string	"%ld\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	$48, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-24(%rbp), %rcx
	leaq	-32(%rbp), %rdx
	leaq	-40(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movq	-40(%rbp), %rdx
	movq	-32(%rbp), %rax
	cmpq	%rax, %rdx
	jnb	.L2
	movq	-40(%rbp), %rax
	addq	$1, %rax
	movq	%rax, -16(%rbp)
	jmp	.L3
.L2:
	movq	-40(%rbp), %rax
	movq	-32(%rbp), %rdx
	subq	%rdx, %rax
	addq	$1, %rax
	andl	$1, %eax
	testq	%rax, %rax
	jne	.L4
	movq	-32(%rbp), %rax
	leaq	2(%rax), %rdx
	movq	-24(%rbp), %rax
	cmpq	%rax, %rdx
	jnb	.L5
	movq	-24(%rbp), %rax
	movq	-32(%rbp), %rcx
	subq	%rcx, %rax
	movq	%rax, %rdx
	movq	-40(%rbp), %rax
	movq	-32(%rbp), %rcx
	subq	%rcx, %rax
	addq	$1, %rax
	imulq	%rdx, %rax
	shrq	%rax
	movq	%rax, %rdx
	movq	-32(%rbp), %rax
	addq	%rdx, %rax
	movq	%rax, -16(%rbp)
	jmp	.L3
.L5:
	movq	-40(%rbp), %rax
	addq	$1, %rax
	movq	%rax, -16(%rbp)
	jmp	.L3
.L4:
	movq	-32(%rbp), %rax
	leaq	2(%rax), %rdx
	movq	-24(%rbp), %rax
	cmpq	%rax, %rdx
	jnb	.L6
	movq	-24(%rbp), %rax
	movq	-32(%rbp), %rcx
	subq	%rcx, %rax
	movq	%rax, %rdx
	movq	-40(%rbp), %rax
	movq	-32(%rbp), %rcx
	subq	%rcx, %rax
	imulq	%rdx, %rax
	shrq	%rax
	movq	%rax, %rdx
	movq	-32(%rbp), %rax
	addq	%rdx, %rax
	addq	$1, %rax
	movq	%rax, -16(%rbp)
	jmp	.L3
.L6:
	movq	-40(%rbp), %rax
	addq	$1, %rax
	movq	%rax, -16(%rbp)
.L3:
	movq	-16(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L8
	call	__stack_chk_fail@PLT
.L8:
	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	"%ld %ld %ld"
.LC1:
	.string	"%ld\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB39:
	.cfi_startproc
	endbr64
	subq	$40, %rsp
	.cfi_def_cfa_offset 48
	leaq	.LC0(%rip), %rdi
	movq	%fs:40, %rax
	movq	%rax, 24(%rsp)
	xorl	%eax, %eax
	leaq	8(%rsp), %rdx
	leaq	16(%rsp), %rcx
	movq	%rsp, %rsi
	call	__isoc99_scanf@PLT
	movq	(%rsp), %rdx
	movq	8(%rsp), %rax
	cmpq	%rax, %rdx
	jnb	.L2
	addq	$1, %rdx
.L3:
	xorl	%eax, %eax
	leaq	.LC1(%rip), %rsi
	movl	$1, %edi
	call	__printf_chk@PLT
	movq	24(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L10
	xorl	%eax, %eax
	addq	$40, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 8
	ret
.L2:
	.cfi_restore_state
	movq	%rdx, %rsi
	movq	16(%rsp), %rcx
	leaq	2(%rax), %rdi
	addq	$1, %rdx
	subq	%rax, %rsi
	leaq	1(%rsi), %r8
	testb	$1, %sil
	je	.L4
	cmpq	%rdi, %rcx
	jbe	.L3
	subq	%rax, %rcx
	imulq	%r8, %rcx
	shrq	%rcx
	leaq	(%rcx,%rax), %rdx
	jmp	.L3
.L4:
	cmpq	%rdi, %rcx
	jbe	.L3
	subq	%rax, %rcx
	imulq	%rsi, %rcx
	shrq	%rcx
	leaq	1(%rax,%rcx), %rdx
	jmp	.L3
.L10:
	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	"%ld %ld %ld"
.LC1:
	.string	"%ld\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB39:
	.cfi_startproc
	endbr64
	subq	$40, %rsp
	.cfi_def_cfa_offset 48
	leaq	.LC0(%rip), %rdi
	movq	%fs:40, %rax
	movq	%rax, 24(%rsp)
	xorl	%eax, %eax
	leaq	8(%rsp), %rdx
	leaq	16(%rsp), %rcx
	movq	%rsp, %rsi
	call	__isoc99_scanf@PLT
	movq	(%rsp), %rdx
	movq	8(%rsp), %rax
	cmpq	%rax, %rdx
	jnb	.L2
	addq	$1, %rdx
.L3:
	xorl	%eax, %eax
	leaq	.LC1(%rip), %rsi
	movl	$1, %edi
	call	__printf_chk@PLT
	movq	24(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L10
	xorl	%eax, %eax
	addq	$40, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 8
	ret
.L2:
	.cfi_restore_state
	movq	%rdx, %rsi
	movq	16(%rsp), %rcx
	leaq	2(%rax), %rdi
	addq	$1, %rdx
	subq	%rax, %rsi
	leaq	1(%rsi), %r8
	testb	$1, %sil
	je	.L4
	cmpq	%rdi, %rcx
	jbe	.L3
	subq	%rax, %rcx
	imulq	%r8, %rcx
	shrq	%rcx
	leaq	(%rcx,%rax), %rdx
	jmp	.L3
.L4:
	cmpq	%rdi, %rcx
	jbe	.L3
	subq	%rax, %rcx
	imulq	%rsi, %rcx
	shrq	%rcx
	leaq	1(%rax,%rcx), %rdx
	jmp	.L3
.L10:
	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>

int main(void)
{
  unsigned long K, A, B, ANS;
  scanf("%ld %ld %ld", &K, &A, &B);
  //printf("K(%ld) A(%ld) B(%ld)\n", K, A, B);

  // 売れない
  if (K < ((A - 1) + 1)) {
    ANS = 1 + K;
  // 売れる
  } else {
    // 最初に叩いた残り回数が偶数の場合
    if ((K - (A - 1)) % 2 == 0) {
      // 売買で儲かる
      if (A + 2 < B) {
        ANS = 1 + (A - 1) + (B - A) * (K - (A - 1)) / 2;
      // 売買で儲からない
      } else {
        ANS = 1 + K;
      }
    // 最初に叩いた残り回数が奇数の場合
    } else {
      // 売買で儲かる
      if (A + 2 < B) {
        ANS = 1 + (A - 1) + (B - A) * (K - (A - 1) - 1) / 2 + 1;
      // 売買で儲からない
      } else {
        ANS = 1 + K;
      }
    }
  }
  printf("%ld\n", ANS);
  return 0;
}
5 2 6
 7 5 4
 314159265 35897932 35610649
 5 3 6
 7 1 4
 3 3 6
 407766107 35897932 14836778
 7 2 6
 407766107 9307229 14836778
 407766107 9307229 25447105

10
 8
 314159266
 7
 11
 4
 407766108
 14
 1101648954500241
 3215538450316794

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>

int main(void)
{
  unsigned long K, A, B, ANS;
  scanf("%ld %ld %ld", &K, &A, &B);
  //printf("K(%ld) A(%ld) B(%ld)\n", K, A, B);

  // 売れない
  if (K < ((A - 1) + 1)) {
    ANS = 1 + K;
  // 売れる
  } else {
    // 最初に叩いた残り回数が偶数の場合
    if ((K - (A - 1)) % 2 == 0) {
      // 売買で儲かる
      if (A + 2 < B) {
        ANS = 1 + (A - 1) + (B - A) * (K - (A - 1)) / 2;
      // 売買で儲からない
      } else {
        ANS = 1 + K;
      }
    // 最初に叩いた残り回数が奇数の場合
    } else {
      // 売買で儲かる
      if (A + 2 < B) {
        ANS = 1 + (A - 1) + (B - A) * (K - (A - 1) - 1) / 2 + 1;
      // 売買で儲からない
      } else {
        ANS = 1 + K;
      }
    }
  }
  printf("%ld\n", ANS);
  return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%ld %ld %ld"
.LC1:
	.string	"%ld\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	$48, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-24(%rbp), %rcx
	leaq	-32(%rbp), %rdx
	leaq	-40(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movq	-40(%rbp), %rdx
	movq	-32(%rbp), %rax
	cmpq	%rax, %rdx
	jnb	.L2
	movq	-40(%rbp), %rax
	addq	$1, %rax
	movq	%rax, -16(%rbp)
	jmp	.L3
.L2:
	movq	-40(%rbp), %rax
	movq	-32(%rbp), %rdx
	subq	%rdx, %rax
	addq	$1, %rax
	andl	$1, %eax
	testq	%rax, %rax
	jne	.L4
	movq	-32(%rbp), %rax
	leaq	2(%rax), %rdx
	movq	-24(%rbp), %rax
	cmpq	%rax, %rdx
	jnb	.L5
	movq	-24(%rbp), %rax
	movq	-32(%rbp), %rcx
	subq	%rcx, %rax
	movq	%rax, %rdx
	movq	-40(%rbp), %rax
	movq	-32(%rbp), %rcx
	subq	%rcx, %rax
	addq	$1, %rax
	imulq	%rdx, %rax
	shrq	%rax
	movq	%rax, %rdx
	movq	-32(%rbp), %rax
	addq	%rdx, %rax
	movq	%rax, -16(%rbp)
	jmp	.L3
.L5:
	movq	-40(%rbp), %rax
	addq	$1, %rax
	movq	%rax, -16(%rbp)
	jmp	.L3
.L4:
	movq	-32(%rbp), %rax
	leaq	2(%rax), %rdx
	movq	-24(%rbp), %rax
	cmpq	%rax, %rdx
	jnb	.L6
	movq	-24(%rbp), %rax
	movq	-32(%rbp), %rcx
	subq	%rcx, %rax
	movq	%rax, %rdx
	movq	-40(%rbp), %rax
	movq	-32(%rbp), %rcx
	subq	%rcx, %rax
	imulq	%rdx, %rax
	shrq	%rax
	movq	%rax, %rdx
	movq	-32(%rbp), %rax
	addq	%rdx, %rax
	addq	$1, %rax
	movq	%rax, -16(%rbp)
	jmp	.L3
.L6:
	movq	-40(%rbp), %rax
	addq	$1, %rax
	movq	%rax, -16(%rbp)
.L3:
	movq	-16(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L8
	call	__stack_chk_fail@PLT
.L8:
	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	"%ld %ld %ld"
.LC1:
	.string	"%ld\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	$48, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-24(%rbp), %rcx
	leaq	-32(%rbp), %rdx
	leaq	-40(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movq	-40(%rbp), %rdx
	movq	-32(%rbp), %rax
	cmpq	%rax, %rdx
	jnb	.L2
	movq	-40(%rbp), %rax
	addq	$1, %rax
	movq	%rax, -16(%rbp)
	jmp	.L3
.L2:
	movq	-40(%rbp), %rax
	movq	-32(%rbp), %rdx
	subq	%rdx, %rax
	addq	$1, %rax
	andl	$1, %eax
	testq	%rax, %rax
	jne	.L4
	movq	-32(%rbp), %rax
	leaq	2(%rax), %rdx
	movq	-24(%rbp), %rax
	cmpq	%rax, %rdx
	jnb	.L5
	movq	-24(%rbp), %rax
	movq	-32(%rbp), %rcx
	subq	%rcx, %rax
	movq	%rax, %rdx
	movq	-40(%rbp), %rax
	movq	-32(%rbp), %rcx
	subq	%rcx, %rax
	addq	$1, %rax
	imulq	%rdx, %rax
	shrq	%rax
	movq	%rax, %rdx
	movq	-32(%rbp), %rax
	addq	%rdx, %rax
	movq	%rax, -16(%rbp)
	jmp	.L3
.L5:
	movq	-40(%rbp), %rax
	addq	$1, %rax
	movq	%rax, -16(%rbp)
	jmp	.L3
.L4:
	movq	-32(%rbp), %rax
	leaq	2(%rax), %rdx
	movq	-24(%rbp), %rax
	cmpq	%rax, %rdx
	jnb	.L6
	movq	-24(%rbp), %rax
	movq	-32(%rbp), %rcx
	subq	%rcx, %rax
	movq	%rax, %rdx
	movq	-40(%rbp), %rax
	movq	-32(%rbp), %rcx
	subq	%rcx, %rax
	imulq	%rdx, %rax
	shrq	%rax
	movq	%rax, %rdx
	movq	-32(%rbp), %rax
	addq	%rdx, %rax
	addq	$1, %rax
	movq	%rax, -16(%rbp)
	jmp	.L3
.L6:
	movq	-40(%rbp), %rax
	addq	$1, %rax
	movq	%rax, -16(%rbp)
.L3:
	movq	-16(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L8
	call	__stack_chk_fail@PLT
.L8:
	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:
