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>

int main(void){
    unsigned long long k,a,b,ans=1,p,q;
    scanf("%llu%llu%llu",&k,&a,&b);
    while(ans<a){
        ans++;
        k--;
        if (k==0){
            printf("%llu\n",ans);
            return 0;
        }
    }
    if (k%2==1){
        k--;
        ans++;
    }
    for (unsigned long long i=0; i<k/2; i++){
        if (ans<a){
            ans+=2;
        } else {
            p=ans+2;
            q=ans-a+b;
            ans=p>q?p:q;
        }
    }
    printf("%llu\n",ans);
    return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%llu%llu%llu"
.LC1:
	.string	"%llu\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB0:
	.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
	movq	$1, -40(%rbp)
	leaq	-48(%rbp), %rcx
	leaq	-56(%rbp), %rdx
	leaq	-64(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	jmp	.L2
.L4:
	addq	$1, -40(%rbp)
	movq	-64(%rbp), %rax
	subq	$1, %rax
	movq	%rax, -64(%rbp)
	movq	-64(%rbp), %rax
	testq	%rax, %rax
	jne	.L2
	movq	-40(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	jmp	.L10
.L2:
	movq	-56(%rbp), %rax
	cmpq	%rax, -40(%rbp)
	jb	.L4
	movq	-64(%rbp), %rax
	andl	$1, %eax
	testq	%rax, %rax
	je	.L5
	movq	-64(%rbp), %rax
	subq	$1, %rax
	movq	%rax, -64(%rbp)
	addq	$1, -40(%rbp)
.L5:
	movq	$0, -32(%rbp)
	jmp	.L6
.L9:
	movq	-56(%rbp), %rax
	cmpq	%rax, -40(%rbp)
	jnb	.L7
	addq	$2, -40(%rbp)
	jmp	.L8
.L7:
	movq	-40(%rbp), %rax
	addq	$2, %rax
	movq	%rax, -24(%rbp)
	movq	-56(%rbp), %rdx
	movq	-40(%rbp), %rax
	subq	%rdx, %rax
	movq	%rax, %rcx
	movq	-48(%rbp), %rax
	addq	%rcx, %rax
	movq	%rax, -16(%rbp)
	movq	-16(%rbp), %rdx
	movq	-24(%rbp), %rax
	cmpq	%rax, %rdx
	cmovnb	%rdx, %rax
	movq	%rax, -40(%rbp)
.L8:
	addq	$1, -32(%rbp)
.L6:
	movq	-64(%rbp), %rax
	shrq	%rax
	cmpq	%rax, -32(%rbp)
	jb	.L9
	movq	-40(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
.L10:
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L11
	call	__stack_chk_fail@PLT
.L11:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.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%llu%llu"
.LC1:
	.string	"%llu\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB23:
	.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	16(%rsp), %rcx
	leaq	8(%rsp), %rdx
	movq	%rsp, %rsi
	call	__isoc99_scanf@PLT
	movq	(%rsp), %r8
	movq	8(%rsp), %rsi
	xorl	%ecx, %ecx
	movl	$1, %edx
	movq	%r8, %rax
	jmp	.L2
	.p2align 4,,10
	.p2align 3
.L4:
	addq	$1, %rdx
	movl	$1, %ecx
	subq	$1, %rax
	je	.L25
.L2:
	cmpq	%rdx, %rsi
	ja	.L4
	testb	%cl, %cl
	je	.L5
	movq	%rax, (%rsp)
	movq	%rax, %r8
.L5:
	testb	$1, %r8b
	je	.L6
	subq	$1, %r8
	addq	$1, %rdx
	movq	%r8, (%rsp)
.L6:
	shrq	%r8
	je	.L7
	movq	16(%rsp), %r9
	xorl	%edi, %edi
	subq	%rsi, %r9
	.p2align 4,,10
	.p2align 3
.L9:
	leaq	2(%rdx), %rcx
	leaq	(%r9,%rdx), %rax
	cmpq	%rcx, %rax
	cmovb	%rcx, %rax
	cmpq	%rdx, %rsi
	cmovbe	%rax, %rcx
	addq	$1, %rdi
	movq	%rcx, %rdx
	cmpq	%rdi, %r8
	jne	.L9
.L7:
	leaq	.LC1(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L3:
	movq	24(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L26
	xorl	%eax, %eax
	addq	$40, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 8
	ret
.L25:
	.cfi_restore_state
	leaq	.LC1(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	movq	$0, (%rsp)
	call	__printf_chk@PLT
	jmp	.L3
.L26:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE23:
	.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%llu%llu"
.LC1:
	.string	"%llu\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB23:
	.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	16(%rsp), %rcx
	leaq	8(%rsp), %rdx
	movq	%rsp, %rsi
	call	__isoc99_scanf@PLT
	movq	(%rsp), %r8
	movq	8(%rsp), %rsi
	xorl	%ecx, %ecx
	movl	$1, %edx
	movq	%r8, %rax
	jmp	.L2
	.p2align 4,,10
	.p2align 3
.L4:
	addq	$1, %rdx
	movl	$1, %ecx
	subq	$1, %rax
	je	.L25
.L2:
	cmpq	%rdx, %rsi
	ja	.L4
	testb	%cl, %cl
	je	.L5
	movq	%rax, (%rsp)
	movq	%rax, %r8
.L5:
	testb	$1, %r8b
	je	.L6
	subq	$1, %r8
	addq	$1, %rdx
	movq	%r8, (%rsp)
.L6:
	shrq	%r8
	je	.L7
	movq	16(%rsp), %r9
	xorl	%edi, %edi
	subq	%rsi, %r9
	.p2align 4,,10
	.p2align 3
.L9:
	leaq	2(%rdx), %rcx
	leaq	(%r9,%rdx), %rax
	cmpq	%rcx, %rax
	cmovb	%rcx, %rax
	cmpq	%rdx, %rsi
	cmovbe	%rax, %rcx
	addq	$1, %rdi
	movq	%rcx, %rdx
	cmpq	%rdi, %r8
	jne	.L9
.L7:
	leaq	.LC1(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L3:
	movq	24(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L26
	xorl	%eax, %eax
	addq	$40, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 8
	ret
.L25:
	.cfi_restore_state
	leaq	.LC1(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	movq	$0, (%rsp)
	call	__printf_chk@PLT
	jmp	.L3
.L26:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE23:
	.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>

int main(void){
    unsigned long long k,a,b,ans=1,p,q;
    scanf("%llu%llu%llu",&k,&a,&b);
    while(ans<a){
        ans++;
        k--;
        if (k==0){
            printf("%llu\n",ans);
            return 0;
        }
    }
    if (k%2==1){
        k--;
        ans++;
    }
    for (unsigned long long i=0; i<k/2; i++){
        if (ans<a){
            ans+=2;
        } else {
            p=ans+2;
            q=ans-a+b;
            ans=p>q?p:q;
        }
    }
    printf("%llu\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>

int main(void){
    unsigned long long k,a,b,ans=1,p,q;
    scanf("%llu%llu%llu",&k,&a,&b);
    while(ans<a){
        ans++;
        k--;
        if (k==0){
            printf("%llu\n",ans);
            return 0;
        }
    }
    if (k%2==1){
        k--;
        ans++;
    }
    for (unsigned long long i=0; i<k/2; i++){
        if (ans<a){
            ans+=2;
        } else {
            p=ans+2;
            q=ans-a+b;
            ans=p>q?p:q;
        }
    }
    printf("%llu\n",ans);
    return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%llu%llu%llu"
.LC1:
	.string	"%llu\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB0:
	.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
	movq	$1, -40(%rbp)
	leaq	-48(%rbp), %rcx
	leaq	-56(%rbp), %rdx
	leaq	-64(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	jmp	.L2
.L4:
	addq	$1, -40(%rbp)
	movq	-64(%rbp), %rax
	subq	$1, %rax
	movq	%rax, -64(%rbp)
	movq	-64(%rbp), %rax
	testq	%rax, %rax
	jne	.L2
	movq	-40(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	jmp	.L10
.L2:
	movq	-56(%rbp), %rax
	cmpq	%rax, -40(%rbp)
	jb	.L4
	movq	-64(%rbp), %rax
	andl	$1, %eax
	testq	%rax, %rax
	je	.L5
	movq	-64(%rbp), %rax
	subq	$1, %rax
	movq	%rax, -64(%rbp)
	addq	$1, -40(%rbp)
.L5:
	movq	$0, -32(%rbp)
	jmp	.L6
.L9:
	movq	-56(%rbp), %rax
	cmpq	%rax, -40(%rbp)
	jnb	.L7
	addq	$2, -40(%rbp)
	jmp	.L8
.L7:
	movq	-40(%rbp), %rax
	addq	$2, %rax
	movq	%rax, -24(%rbp)
	movq	-56(%rbp), %rdx
	movq	-40(%rbp), %rax
	subq	%rdx, %rax
	movq	%rax, %rcx
	movq	-48(%rbp), %rax
	addq	%rcx, %rax
	movq	%rax, -16(%rbp)
	movq	-16(%rbp), %rdx
	movq	-24(%rbp), %rax
	cmpq	%rax, %rdx
	cmovnb	%rdx, %rax
	movq	%rax, -40(%rbp)
.L8:
	addq	$1, -32(%rbp)
.L6:
	movq	-64(%rbp), %rax
	shrq	%rax
	cmpq	%rax, -32(%rbp)
	jb	.L9
	movq	-40(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
.L10:
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L11
	call	__stack_chk_fail@PLT
.L11:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.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%llu%llu"
.LC1:
	.string	"%llu\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB0:
	.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
	movq	$1, -40(%rbp)
	leaq	-48(%rbp), %rcx
	leaq	-56(%rbp), %rdx
	leaq	-64(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	jmp	.L2
.L4:
	addq	$1, -40(%rbp)
	movq	-64(%rbp), %rax
	subq	$1, %rax
	movq	%rax, -64(%rbp)
	movq	-64(%rbp), %rax
	testq	%rax, %rax
	jne	.L2
	movq	-40(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
	jmp	.L10
.L2:
	movq	-56(%rbp), %rax
	cmpq	%rax, -40(%rbp)
	jb	.L4
	movq	-64(%rbp), %rax
	andl	$1, %eax
	testq	%rax, %rax
	je	.L5
	movq	-64(%rbp), %rax
	subq	$1, %rax
	movq	%rax, -64(%rbp)
	addq	$1, -40(%rbp)
.L5:
	movq	$0, -32(%rbp)
	jmp	.L6
.L9:
	movq	-56(%rbp), %rax
	cmpq	%rax, -40(%rbp)
	jnb	.L7
	addq	$2, -40(%rbp)
	jmp	.L8
.L7:
	movq	-40(%rbp), %rax
	addq	$2, %rax
	movq	%rax, -24(%rbp)
	movq	-56(%rbp), %rdx
	movq	-40(%rbp), %rax
	subq	%rdx, %rax
	movq	%rax, %rcx
	movq	-48(%rbp), %rax
	addq	%rcx, %rax
	movq	%rax, -16(%rbp)
	movq	-16(%rbp), %rdx
	movq	-24(%rbp), %rax
	cmpq	%rax, %rdx
	cmovnb	%rdx, %rax
	movq	%rax, -40(%rbp)
.L8:
	addq	$1, -32(%rbp)
.L6:
	movq	-64(%rbp), %rax
	shrq	%rax
	cmpq	%rax, -32(%rbp)
	jb	.L9
	movq	-40(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
.L10:
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L11
	call	__stack_chk_fail@PLT
.L11:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE0:
	.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:
