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>
#include <string.h>
#include <math.h>

long long int lucas(int N)
{
	int i, j, k;
	long long int result = 0, before;
	if (N == 1)
		return 1;
	else {	
		for (i = 1; i <= N; i++) {
			if (i == 1) {
				result = 1;
				before = 2;
			} else {
				long long int tmp = result;
				result = result + before;
				before = tmp;
			}
		}
		return result;
	}

}

int main()
{
	int N;
	scanf("%d", &N);

	int i, j, k;

	printf("%lld\n", lucas(N));

	return 0;
}
```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	lucas
	.type	lucas, @function
lucas:
.LFB6:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	%edi, -36(%rbp)
	movq	$0, -24(%rbp)
	cmpl	$1, -36(%rbp)
	jne	.L2
	movl	$1, %eax
	jmp	.L3
.L2:
	movl	$1, -28(%rbp)
	jmp	.L4
.L7:
	cmpl	$1, -28(%rbp)
	jne	.L5
	movq	$1, -24(%rbp)
	movq	$2, -16(%rbp)
	jmp	.L6
.L5:
	movq	-24(%rbp), %rax
	movq	%rax, -8(%rbp)
	movq	-16(%rbp), %rax
	addq	%rax, -24(%rbp)
	movq	-8(%rbp), %rax
	movq	%rax, -16(%rbp)
.L6:
	addl	$1, -28(%rbp)
.L4:
	movl	-28(%rbp), %eax
	cmpl	-36(%rbp), %eax
	jle	.L7
	movq	-24(%rbp), %rax
.L3:
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	lucas, .-lucas
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%lld\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB7:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$16, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-12(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-12(%rbp), %eax
	movl	%eax, %edi
	call	lucas
	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	.L10
	call	__stack_chk_fail@PLT
.L10:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.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	lucas
	.type	lucas, @function
lucas:
.LFB51:
	.cfi_startproc
	endbr64
	movl	$1, %r8d
	cmpl	$1, %edi
	je	.L1
	testl	%edi, %edi
	jle	.L6
	xorl	%edx, %edx
	movl	$1, %eax
	jmp	.L4
	.p2align 4,,10
	.p2align 3
.L10:
	leaq	(%rdx,%rcx), %r8
	cmpl	%edi, %eax
	jg	.L1
.L3:
	movq	%rdx, %rcx
	movq	%r8, %rdx
.L4:
	addl	$1, %eax
	cmpl	$2, %eax
	jne	.L10
	movl	$2, %edx
	movl	$1, %r8d
	jmp	.L3
	.p2align 4,,10
	.p2align 3
.L6:
	xorl	%r8d, %r8d
.L1:
	movq	%r8, %rax
	ret
	.cfi_endproc
.LFE51:
	.size	lucas, .-lucas
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d"
.LC1:
	.string	"%lld\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB52:
	.cfi_startproc
	endbr64
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset 3, -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), %rsi
	call	__isoc99_scanf@PLT
	movl	4(%rsp), %ecx
	movl	$1, %r8d
	cmpl	$1, %ecx
	je	.L12
	testl	%ecx, %ecx
	jle	.L17
	xorl	%edx, %edx
	movl	$1, %eax
	jmp	.L14
	.p2align 4,,10
	.p2align 3
.L21:
	leaq	(%rdx,%rbx), %r8
	cmpl	%eax, %ecx
	jl	.L12
.L13:
	movq	%rdx, %rbx
	movq	%r8, %rdx
.L14:
	addl	$1, %eax
	cmpl	$2, %eax
	jne	.L21
	movl	$2, %edx
	movl	$1, %r8d
	jmp	.L13
.L17:
	xorl	%r8d, %r8d
	.p2align 4,,10
	.p2align 3
.L12:
	xorl	%eax, %eax
	movq	%r8, %rdx
	movl	$1, %edi
	leaq	.LC1(%rip), %rsi
	call	__printf_chk@PLT
	movq	8(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L22
	addq	$16, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 16
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 8
	ret
.L22:
	.cfi_restore_state
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE52:
	.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	lucas
	.type	lucas, @function
lucas:
.LFB51:
	.cfi_startproc
	endbr64
	movl	$1, %r8d
	cmpl	$1, %edi
	je	.L1
	testl	%edi, %edi
	jle	.L6
	xorl	%edx, %edx
	movl	$1, %eax
	jmp	.L4
	.p2align 4,,10
	.p2align 3
.L10:
	leaq	(%rdx,%rcx), %r8
	cmpl	%edi, %eax
	jg	.L1
.L3:
	movq	%rdx, %rcx
	movq	%r8, %rdx
.L4:
	addl	$1, %eax
	cmpl	$2, %eax
	jne	.L10
	movl	$2, %edx
	movl	$1, %r8d
	jmp	.L3
	.p2align 4,,10
	.p2align 3
.L6:
	xorl	%r8d, %r8d
.L1:
	movq	%r8, %rax
	ret
	.cfi_endproc
.LFE51:
	.size	lucas, .-lucas
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%d"
.LC1:
	.string	"%lld\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB52:
	.cfi_startproc
	endbr64
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset 3, -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), %rsi
	call	__isoc99_scanf@PLT
	movl	4(%rsp), %ecx
	movl	$1, %r8d
	cmpl	$1, %ecx
	je	.L12
	testl	%ecx, %ecx
	jle	.L17
	xorl	%edx, %edx
	movl	$1, %eax
	jmp	.L14
	.p2align 4,,10
	.p2align 3
.L21:
	leaq	(%rdx,%rbx), %r8
	cmpl	%eax, %ecx
	jl	.L12
.L13:
	movq	%rdx, %rbx
	movq	%r8, %rdx
.L14:
	addl	$1, %eax
	cmpl	$2, %eax
	jne	.L21
	movl	$2, %edx
	movl	$1, %r8d
	jmp	.L13
.L17:
	xorl	%r8d, %r8d
	.p2align 4,,10
	.p2align 3
.L12:
	xorl	%eax, %eax
	movq	%r8, %rdx
	movl	$1, %edi
	leaq	.LC1(%rip), %rsi
	call	__printf_chk@PLT
	movq	8(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L22
	addq	$16, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 16
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 8
	ret
.L22:
	.cfi_restore_state
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE52:
	.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>
#include <string.h>
#include <math.h>

long long int lucas(int N)
{
	int i, j, k;
	long long int result = 0, before;
	if (N == 1)
		return 1;
	else {	
		for (i = 1; i <= N; i++) {
			if (i == 1) {
				result = 1;
				before = 2;
			} else {
				long long int tmp = result;
				result = result + before;
				before = tmp;
			}
		}
		return result;
	}

}

int main()
{
	int N;
	scanf("%d", &N);

	int i, j, k;

	printf("%lld\n", lucas(N));

	return 0;
}

1
 2
 4
 3
 30
 49
 6
 8
 7
 58

1
 3
 7
 4
 1860498
 17393796001
 18
 47
 29
 1322157322203

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>
#include <string.h>
#include <math.h>

long long int lucas(int N)
{
	int i, j, k;
	long long int result = 0, before;
	if (N == 1)
		return 1;
	else {	
		for (i = 1; i <= N; i++) {
			if (i == 1) {
				result = 1;
				before = 2;
			} else {
				long long int tmp = result;
				result = result + before;
				before = tmp;
			}
		}
		return result;
	}

}

int main()
{
	int N;
	scanf("%d", &N);

	int i, j, k;

	printf("%lld\n", lucas(N));

	return 0;
}
```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	lucas
	.type	lucas, @function
lucas:
.LFB6:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	%edi, -36(%rbp)
	movq	$0, -24(%rbp)
	cmpl	$1, -36(%rbp)
	jne	.L2
	movl	$1, %eax
	jmp	.L3
.L2:
	movl	$1, -28(%rbp)
	jmp	.L4
.L7:
	cmpl	$1, -28(%rbp)
	jne	.L5
	movq	$1, -24(%rbp)
	movq	$2, -16(%rbp)
	jmp	.L6
.L5:
	movq	-24(%rbp), %rax
	movq	%rax, -8(%rbp)
	movq	-16(%rbp), %rax
	addq	%rax, -24(%rbp)
	movq	-8(%rbp), %rax
	movq	%rax, -16(%rbp)
.L6:
	addl	$1, -28(%rbp)
.L4:
	movl	-28(%rbp), %eax
	cmpl	-36(%rbp), %eax
	jle	.L7
	movq	-24(%rbp), %rax
.L3:
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	lucas, .-lucas
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%lld\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB7:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$16, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-12(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-12(%rbp), %eax
	movl	%eax, %edi
	call	lucas
	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	.L10
	call	__stack_chk_fail@PLT
.L10:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.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	lucas
	.type	lucas, @function
lucas:
.LFB6:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movl	%edi, -36(%rbp)
	movq	$0, -24(%rbp)
	cmpl	$1, -36(%rbp)
	jne	.L2
	movl	$1, %eax
	jmp	.L3
.L2:
	movl	$1, -28(%rbp)
	jmp	.L4
.L7:
	cmpl	$1, -28(%rbp)
	jne	.L5
	movq	$1, -24(%rbp)
	movq	$2, -16(%rbp)
	jmp	.L6
.L5:
	movq	-24(%rbp), %rax
	movq	%rax, -8(%rbp)
	movq	-16(%rbp), %rax
	addq	%rax, -24(%rbp)
	movq	-8(%rbp), %rax
	movq	%rax, -16(%rbp)
.L6:
	addl	$1, -28(%rbp)
.L4:
	movl	-28(%rbp), %eax
	cmpl	-36(%rbp), %eax
	jle	.L7
	movq	-24(%rbp), %rax
.L3:
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	lucas, .-lucas
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%lld\n"
	.text
	.globl	main
	.type	main, @function
main:
.LFB7:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$16, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-12(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-12(%rbp), %eax
	movl	%eax, %edi
	call	lucas
	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	.L10
	call	__stack_chk_fail@PLT
.L10:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.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:
