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

```c
//  Twitter@KonoLv1 2020年春からエンジニア見習いデビュー！（修正版）
 
//  標準入出力を扱うヘッダーファイルの読み込み
#include <stdio.h>
 
int main(void){
 
    unsigned long int a;
    unsigned long int b;
    unsigned long int n;
    unsigned long int ans = 0;
 
    scanf("%lu %lu %lu",&n,&a,&b);
    
    //  aとbの間隔が奇数か偶数かの判定
    if ((b - a) % 2 == 0){
        
        //  偶数なら間隔÷２で最小
        printf("%lu",((b - a) / 2));
        
    }else{

        //  奇数ならbとaのどちらが対なる端に近いか判定
        //  aかbが一度端に2連続で存在することによりその後交差することなく合流できる。
        
        if (b - 1 <= n - a){
            ans = (((b - a) / 2) + 1) +  (a - 1);
        }else{
            ans = (((b - a) / 2) + 1) + (n - b);
        }
        printf("%lu",ans);
    }
}
 ```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%lu %lu %lu"
.LC1:
	.string	"%lu"
	.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	$48, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movq	$0, -16(%rbp)
	leaq	-32(%rbp), %rcx
	leaq	-40(%rbp), %rdx
	leaq	-24(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movq	-32(%rbp), %rax
	movq	-40(%rbp), %rdx
	subq	%rdx, %rax
	andl	$1, %eax
	testq	%rax, %rax
	jne	.L2
	movq	-32(%rbp), %rax
	movq	-40(%rbp), %rdx
	subq	%rdx, %rax
	shrq	%rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	jmp	.L3
.L2:
	movq	-32(%rbp), %rax
	leaq	-1(%rax), %rdx
	movq	-24(%rbp), %rax
	movq	-40(%rbp), %rcx
	subq	%rcx, %rax
	cmpq	%rax, %rdx
	ja	.L4
	movq	-32(%rbp), %rax
	movq	-40(%rbp), %rdx
	subq	%rdx, %rax
	shrq	%rax
	movq	%rax, %rdx
	movq	-40(%rbp), %rax
	addq	%rdx, %rax
	movq	%rax, -16(%rbp)
	jmp	.L5
.L4:
	movq	-32(%rbp), %rax
	movq	-40(%rbp), %rdx
	subq	%rdx, %rax
	shrq	%rax
	movq	%rax, %rcx
	movq	-24(%rbp), %rax
	movq	-32(%rbp), %rdx
	subq	%rdx, %rax
	addq	%rcx, %rax
	addq	$1, %rax
	movq	%rax, -16(%rbp)
.L5:
	movq	-16(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L3:
	movl	$0, %eax
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L7
	call	__stack_chk_fail@PLT
.L7:
	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	"%lu %lu %lu"
.LC1:
	.string	"%lu"
	.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	8(%rsp), %rcx
	movq	%rsp, %rdx
	leaq	16(%rsp), %rsi
	call	__isoc99_scanf@PLT
	movq	8(%rsp), %rcx
	movq	(%rsp), %rax
	movq	%rcx, %rdx
	subq	%rax, %rdx
	testb	$1, %dl
	je	.L9
	movq	16(%rsp), %rsi
	leaq	-1(%rcx), %r8
	shrq	%rdx
	movq	%rsi, %rdi
	subq	%rax, %rdi
	cmpq	%rdi, %r8
	jbe	.L10
	subq	%rcx, %rsi
	leaq	1(%rsi,%rdx), %rdx
.L5:
	leaq	.LC1(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L3:
	movq	24(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L11
	xorl	%eax, %eax
	addq	$40, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 8
	ret
.L10:
	.cfi_restore_state
	addq	%rax, %rdx
	jmp	.L5
.L9:
	shrq	%rdx
	leaq	.LC1(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L3
.L11:
	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	"%lu %lu %lu"
.LC1:
	.string	"%lu"
	.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	8(%rsp), %rcx
	movq	%rsp, %rdx
	leaq	16(%rsp), %rsi
	call	__isoc99_scanf@PLT
	movq	8(%rsp), %rcx
	movq	(%rsp), %rax
	movq	%rcx, %rdx
	subq	%rax, %rdx
	testb	$1, %dl
	je	.L9
	movq	16(%rsp), %rsi
	leaq	-1(%rcx), %r8
	shrq	%rdx
	movq	%rsi, %rdi
	subq	%rax, %rdi
	cmpq	%rdi, %r8
	jbe	.L10
	subq	%rcx, %rsi
	leaq	1(%rsi,%rdx), %rdx
.L5:
	leaq	.LC1(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
.L3:
	movq	24(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L11
	xorl	%eax, %eax
	addq	$40, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 8
	ret
.L10:
	.cfi_restore_state
	addq	%rax, %rdx
	jmp	.L5
.L9:
	shrq	%rdx
	leaq	.LC1(%rip), %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L3
.L11:
	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:

//  Twitter@KonoLv1 2020年春からエンジニア見習いデビュー！（修正版）
 
//  標準入出力を扱うヘッダーファイルの読み込み
#include <stdio.h>
 
int main(void){
 
    unsigned long int a;
    unsigned long int b;
    unsigned long int n;
    unsigned long int ans = 0;
 
    scanf("%lu %lu %lu",&n,&a,&b);
    
    //  aとbの間隔が奇数か偶数かの判定
    if ((b - a) % 2 == 0){
        
        //  偶数なら間隔÷２で最小
        printf("%lu",((b - a) / 2));
        
    }else{

        //  奇数ならbとaのどちらが対なる端に近いか判定
        //  aかbが一度端に2連続で存在することによりその後交差することなく合流できる。
        
        if (b - 1 <= n - a){
            ans = (((b - a) / 2) + 1) +  (a - 1);
        }else{
            ans = (((b - a) / 2) + 1) + (n - b);
        }
        printf("%lu",ans);
    }
}
 
4 2 3
 5 2 8
 6 3 3
 6 3 5
 1 2 5
 0 3 4
 2 -1 0
 5 2 16
 5 2 27
 10 4 5

2 3 0 1 3 3 3 7 18446744073709551607 4
Given the following C code and unoptimized assembly code, your task is to generate highly optimized x86-64 assembly code.
C Code:

```c
//  Twitter@KonoLv1 2020年春からエンジニア見習いデビュー！（修正版）
 
//  標準入出力を扱うヘッダーファイルの読み込み
#include <stdio.h>
 
int main(void){
 
    unsigned long int a;
    unsigned long int b;
    unsigned long int n;
    unsigned long int ans = 0;
 
    scanf("%lu %lu %lu",&n,&a,&b);
    
    //  aとbの間隔が奇数か偶数かの判定
    if ((b - a) % 2 == 0){
        
        //  偶数なら間隔÷２で最小
        printf("%lu",((b - a) / 2));
        
    }else{

        //  奇数ならbとaのどちらが対なる端に近いか判定
        //  aかbが一度端に2連続で存在することによりその後交差することなく合流できる。
        
        if (b - 1 <= n - a){
            ans = (((b - a) / 2) + 1) +  (a - 1);
        }else{
            ans = (((b - a) / 2) + 1) + (n - b);
        }
        printf("%lu",ans);
    }
}
 ```

Unoptimized Assembly Code:

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