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>
#define MOD 1000000007
#define N 100000

int main() {
	int num,i,j=0;
	long A[N];
	long count=1;
	int hat[3]={0,0,0};
	int hatnum=0;
	scanf("%d",&num);
	for(i=0; i<num; i++) {
    	scanf("%ld", &A[i]);
    }
	for(i=0; i<num; i++) {
		if(A[i]==hat[0]) {
			hatnum++;
			j=0;
		}
		if(A[i]==hat[1]) {
			hatnum++;
			j=1;
		}
		if(A[i]==hat[2]) {
			hatnum++;
			j=2;
		}
		switch(hatnum) {
			case 0:
				printf("0");
				return 0;
				break;
			case 1:
				break;
			case 2:
				count*=2;
				break;
			case 3:
				count*=3;
				break;
			default :
				printf("0");
				return 0;
				break;
		}
		hat[j]++;
		hatnum=0;
		if(count>MOD) {
			count %= MOD;
		}
	}
	printf("%ld",count);
	return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%ld"
	.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
	leaq	-798720(%rsp), %r11
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	subq	$1344, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	$0, -800048(%rbp)
	movq	$1, -800040(%rbp)
	movl	$0, -800028(%rbp)
	movl	$0, -800024(%rbp)
	movl	$0, -800020(%rbp)
	movl	$0, -800044(%rbp)
	leaq	-800056(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -800052(%rbp)
	jmp	.L2
.L3:
	leaq	-800016(%rbp), %rdx
	movl	-800052(%rbp), %eax
	cltq
	salq	$3, %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -800052(%rbp)
.L2:
	movl	-800056(%rbp), %eax
	cmpl	%eax, -800052(%rbp)
	jl	.L3
	movl	$0, -800052(%rbp)
	jmp	.L4
.L16:
	movl	-800052(%rbp), %eax
	cltq
	movq	-800016(%rbp,%rax,8), %rdx
	movl	-800028(%rbp), %eax
	cltq
	cmpq	%rax, %rdx
	jne	.L5
	addl	$1, -800044(%rbp)
	movl	$0, -800048(%rbp)
.L5:
	movl	-800052(%rbp), %eax
	cltq
	movq	-800016(%rbp,%rax,8), %rdx
	movl	-800024(%rbp), %eax
	cltq
	cmpq	%rax, %rdx
	jne	.L6
	addl	$1, -800044(%rbp)
	movl	$1, -800048(%rbp)
.L6:
	movl	-800052(%rbp), %eax
	cltq
	movq	-800016(%rbp,%rax,8), %rdx
	movl	-800020(%rbp), %eax
	cltq
	cmpq	%rax, %rdx
	jne	.L7
	addl	$1, -800044(%rbp)
	movl	$2, -800048(%rbp)
.L7:
	cmpl	$3, -800044(%rbp)
	je	.L8
	cmpl	$3, -800044(%rbp)
	jg	.L9
	cmpl	$2, -800044(%rbp)
	je	.L10
	cmpl	$2, -800044(%rbp)
	jg	.L9
	cmpl	$0, -800044(%rbp)
	je	.L11
	cmpl	$1, -800044(%rbp)
	je	.L19
	jmp	.L9
.L11:
	movl	$48, %edi
	call	putchar@PLT
	movl	$0, %eax
	jmp	.L17
.L10:
	salq	-800040(%rbp)
	jmp	.L14
.L8:
	movq	-800040(%rbp), %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	movq	%rax, -800040(%rbp)
	jmp	.L14
.L9:
	movl	$48, %edi
	call	putchar@PLT
	movl	$0, %eax
	jmp	.L17
.L19:
	nop
.L14:
	movl	-800048(%rbp), %eax
	cltq
	movl	-800028(%rbp,%rax,4), %eax
	leal	1(%rax), %edx
	movl	-800048(%rbp), %eax
	cltq
	movl	%edx, -800028(%rbp,%rax,4)
	movl	$0, -800044(%rbp)
	cmpq	$1000000007, -800040(%rbp)
	jle	.L15
	movq	-800040(%rbp), %rcx
	movabsq	$-8543223828751151131, %rdx
	movq	%rcx, %rax
	imulq	%rdx
	leaq	(%rdx,%rcx), %rax
	sarq	$29, %rax
	movq	%rcx, %rdx
	sarq	$63, %rdx
	subq	%rdx, %rax
	imulq	$1000000007, %rax, %rdx
	movq	%rcx, %rax
	subq	%rdx, %rax
	movq	%rax, -800040(%rbp)
.L15:
	addl	$1, -800052(%rbp)
.L4:
	movl	-800056(%rbp), %eax
	cmpl	%eax, -800052(%rbp)
	jl	.L16
	movq	-800040(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
.L17:
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L18
	call	__stack_chk_fail@PLT
.L18:
	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	"%d"
.LC1:
	.string	"%ld"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB23:
	.cfi_startproc
	endbr64
	pushq	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	pushq	%r13
	.cfi_def_cfa_offset 24
	.cfi_offset 13, -24
	pushq	%r12
	.cfi_def_cfa_offset 32
	.cfi_offset 12, -32
	pushq	%rbp
	.cfi_def_cfa_offset 40
	.cfi_offset 6, -40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	leaq	-798720(%rsp), %r11
	.cfi_def_cfa 11, 798768
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	.cfi_def_cfa_register 7
	subq	$1328, %rsp
	.cfi_def_cfa_offset 800096
	leaq	.LC0(%rip), %rdi
	leaq	.LC1(%rip), %r13
	movq	%fs:40, %rax
	movq	%rax, 800040(%rsp)
	xorl	%eax, %eax
	leaq	12(%rsp), %rsi
	movl	$0, 24(%rsp)
	movq	$0, 16(%rsp)
	call	__isoc99_scanf@PLT
	movl	12(%rsp), %eax
	testl	%eax, %eax
	jle	.L2
	leaq	32(%rsp), %r12
	xorl	%ebx, %ebx
	leaq	.LC1(%rip), %r13
	movq	%r12, %rbp
	.p2align 4,,10
	.p2align 3
.L3:
	movq	%rbp, %rsi
	movq	%r13, %rdi
	xorl	%eax, %eax
	addl	$1, %ebx
	call	__isoc99_scanf@PLT
	movl	12(%rsp), %eax
	addq	$8, %rbp
	cmpl	%ebx, %eax
	jg	.L3
	testl	%eax, %eax
	jle	.L2
	subl	$1, %eax
	xorl	%ecx, %ecx
	xorl	%ebp, %ebp
	xorl	%r14d, %r14d
	leaq	8(%r12,%rax,8), %r9
	movl	$1, %r8d
	xorl	%eax, %eax
	xorl	%esi, %esi
	movabsq	$-8543223828751151131, %r10
	xorl	%edi, %edi
.L13:
	movq	(%r12), %rdx
	movslq	%eax, %rbx
	cmpq	%rbx, %rdx
	sete	%r11b
	cmove	%eax, %ecx
	sete	%al
	movzbl	%r11b, %r11d
	movzbl	%al, %eax
	addl	$1, %r11d
	cmpq	%rbx, %rdx
	movslq	%r14d, %rbx
	cmove	%edi, %esi
	cmpq	%rbx, %rdx
	je	.L31
	movslq	%ebp, %r11
	cmpq	%r11, %rdx
	je	.L15
.L14:
	cmpl	$1, %eax
	je	.L9
	movl	$48, %edi
	call	putchar@PLT
.L10:
	movq	800040(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L32
	addq	$800048, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 48
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%rbp
	.cfi_def_cfa_offset 32
	popq	%r12
	.cfi_def_cfa_offset 24
	popq	%r13
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	ret
.L34:
	.cfi_restore_state
	movl	%r11d, %eax
.L15:
	leal	1(%rax), %esi
	cmpl	$1, %eax
	je	.L19
	cmpl	$3, %esi
	jne	.L33
	leaq	(%r8,%r8,2), %r8
	movl	%ebp, %ecx
	movl	$2, %esi
.L9:
	addl	$1, %ecx
	movslq	%esi, %rax
	movl	%ecx, 16(%rsp,%rax,4)
	cmpq	$1000000007, %r8
	jle	.L11
	movq	%r8, %rax
	imulq	%r10
	leaq	(%rdx,%r8), %rax
	movq	%r8, %rdx
	sarq	$29, %rax
	sarq	$63, %rdx
	subq	%rdx, %rax
	imulq	$1000000007, %rax, %rax
	subq	%rax, %r8
.L11:
	addq	$8, %r12
	cmpq	%r12, %r9
	je	.L12
	movl	16(%rsp), %eax
	movl	20(%rsp), %r14d
	movl	24(%rsp), %ebp
	jmp	.L13
	.p2align 4,,10
	.p2align 3
.L31:
	movslq	%ebp, %rax
	cmpq	%rax, %rdx
	je	.L34
	movl	%r14d, %ecx
	movl	$1, %esi
	movl	%r11d, %eax
	cmpl	$2, %r11d
	jne	.L14
.L7:
	addq	%r8, %r8
	jmp	.L9
.L33:
	movl	%esi, %eax
	movl	%ebp, %ecx
	movl	$2, %esi
	jmp	.L14
.L19:
	movl	%ebp, %ecx
	jmp	.L7
.L2:
	movl	$1, %r8d
.L12:
	movq	%r8, %rdx
	movq	%r13, %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L10
.L32:
	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	"%d"
.LC1:
	.string	"%ld"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB23:
	.cfi_startproc
	endbr64
	pushq	%r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	pushq	%r13
	.cfi_def_cfa_offset 24
	.cfi_offset 13, -24
	pushq	%r12
	.cfi_def_cfa_offset 32
	.cfi_offset 12, -32
	pushq	%rbp
	.cfi_def_cfa_offset 40
	.cfi_offset 6, -40
	pushq	%rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	leaq	-798720(%rsp), %r11
	.cfi_def_cfa 11, 798768
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	.cfi_def_cfa_register 7
	subq	$1328, %rsp
	.cfi_def_cfa_offset 800096
	leaq	.LC0(%rip), %rdi
	leaq	.LC1(%rip), %r13
	movq	%fs:40, %rax
	movq	%rax, 800040(%rsp)
	xorl	%eax, %eax
	leaq	12(%rsp), %rsi
	movl	$0, 24(%rsp)
	movq	$0, 16(%rsp)
	call	__isoc99_scanf@PLT
	movl	12(%rsp), %eax
	testl	%eax, %eax
	jle	.L2
	leaq	32(%rsp), %r12
	xorl	%ebx, %ebx
	leaq	.LC1(%rip), %r13
	movq	%r12, %rbp
	.p2align 4,,10
	.p2align 3
.L3:
	movq	%rbp, %rsi
	movq	%r13, %rdi
	xorl	%eax, %eax
	addl	$1, %ebx
	call	__isoc99_scanf@PLT
	movl	12(%rsp), %eax
	addq	$8, %rbp
	cmpl	%ebx, %eax
	jg	.L3
	testl	%eax, %eax
	jle	.L2
	subl	$1, %eax
	xorl	%ecx, %ecx
	xorl	%ebp, %ebp
	xorl	%r14d, %r14d
	leaq	8(%r12,%rax,8), %r9
	movl	$1, %r8d
	xorl	%eax, %eax
	xorl	%esi, %esi
	movabsq	$-8543223828751151131, %r10
	xorl	%edi, %edi
.L13:
	movq	(%r12), %rdx
	movslq	%eax, %rbx
	cmpq	%rbx, %rdx
	sete	%r11b
	cmove	%eax, %ecx
	sete	%al
	movzbl	%r11b, %r11d
	movzbl	%al, %eax
	addl	$1, %r11d
	cmpq	%rbx, %rdx
	movslq	%r14d, %rbx
	cmove	%edi, %esi
	cmpq	%rbx, %rdx
	je	.L31
	movslq	%ebp, %r11
	cmpq	%r11, %rdx
	je	.L15
.L14:
	cmpl	$1, %eax
	je	.L9
	movl	$48, %edi
	call	putchar@PLT
.L10:
	movq	800040(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L32
	addq	$800048, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 48
	xorl	%eax, %eax
	popq	%rbx
	.cfi_def_cfa_offset 40
	popq	%rbp
	.cfi_def_cfa_offset 32
	popq	%r12
	.cfi_def_cfa_offset 24
	popq	%r13
	.cfi_def_cfa_offset 16
	popq	%r14
	.cfi_def_cfa_offset 8
	ret
.L34:
	.cfi_restore_state
	movl	%r11d, %eax
.L15:
	leal	1(%rax), %esi
	cmpl	$1, %eax
	je	.L19
	cmpl	$3, %esi
	jne	.L33
	leaq	(%r8,%r8,2), %r8
	movl	%ebp, %ecx
	movl	$2, %esi
.L9:
	addl	$1, %ecx
	movslq	%esi, %rax
	movl	%ecx, 16(%rsp,%rax,4)
	cmpq	$1000000007, %r8
	jle	.L11
	movq	%r8, %rax
	imulq	%r10
	leaq	(%rdx,%r8), %rax
	movq	%r8, %rdx
	sarq	$29, %rax
	sarq	$63, %rdx
	subq	%rdx, %rax
	imulq	$1000000007, %rax, %rax
	subq	%rax, %r8
.L11:
	addq	$8, %r12
	cmpq	%r12, %r9
	je	.L12
	movl	16(%rsp), %eax
	movl	20(%rsp), %r14d
	movl	24(%rsp), %ebp
	jmp	.L13
	.p2align 4,,10
	.p2align 3
.L31:
	movslq	%ebp, %rax
	cmpq	%rax, %rdx
	je	.L34
	movl	%r14d, %ecx
	movl	$1, %esi
	movl	%r11d, %eax
	cmpl	$2, %r11d
	jne	.L14
.L7:
	addq	%r8, %r8
	jmp	.L9
.L33:
	movl	%esi, %eax
	movl	%ebp, %ecx
	movl	$2, %esi
	jmp	.L14
.L19:
	movl	%ebp, %ecx
	jmp	.L7
.L2:
	movl	$1, %r8d
.L12:
	movq	%r8, %rdx
	movq	%r13, %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	call	__printf_chk@PLT
	jmp	.L10
.L32:
	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>
#define MOD 1000000007
#define N 100000

int main() {
	int num,i,j=0;
	long A[N];
	long count=1;
	int hat[3]={0,0,0};
	int hatnum=0;
	scanf("%d",&num);
	for(i=0; i<num; i++) {
    	scanf("%ld", &A[i]);
    }
	for(i=0; i<num; i++) {
		if(A[i]==hat[0]) {
			hatnum++;
			j=0;
		}
		if(A[i]==hat[1]) {
			hatnum++;
			j=1;
		}
		if(A[i]==hat[2]) {
			hatnum++;
			j=2;
		}
		switch(hatnum) {
			case 0:
				printf("0");
				return 0;
				break;
			case 1:
				break;
			case 2:
				count*=2;
				break;
			case 3:
				count*=3;
				break;
			default :
				printf("0");
				return 0;
				break;
		}
		hat[j]++;
		hatnum=0;
		if(count>MOD) {
			count %= MOD;
		}
	}
	printf("%ld",count);
	return 0;
}
54
0 0 1 0 1 2 1 2 3 2 3 3 4 4 5 4 6 5 7 8 5 6 6 7 7 8 8 9 9 10 10 11 9 12 10 13 14 11 11 12 12 20 13 14 14 15 15 15 16 16 16 17 17 17
 6
0 1 2 0 3 4
 6
0 1 1 3 4 5
 54
0 0 1 0 1 2 1 2 3 2 3 3 4 4 5 4 6 5 7 8 5 6 6 7 7 8 8 9 9 10 10 11 9 12 10 13 14 11 11 12 12 9 13 14 14 15 15 15 16 16 16 17 17 17
 6
0 1 0 3 4 5
 54
0 0 1 0 1 2 1 2 3 2 3 3 2 4 5 4 6 5 7 8 5 6 6 7 7 8 8 9 9 10 10 11 9 12 10 13 14 11 11 12 12 9 13 14 14 15 15 15 16 16 16 17 17 17
 6
0 1 0 1 4 5
 54
0 0 1 0 1 2 1 2 6 2 3 3 2 4 5 4 6 5 7 8 5 6 6 7 7 8 8 9 9 10 10 11 9 12 10 13 14 11 11 12 12 9 13 14 14 15 15 15 16 16 16 17 17 17
 6
0 1 0 1 2 5
 54
0 0 1 0 1 2 1 2 6 2 3 3 2 4 5 4 6 5 7 8 5 6 6 7 7 7 8 9 9 10 10 11 9 12 10 13 14 11 11 12 12 9 13 14 14 15 15 15 16 16 16 17 17 17

0 6 0 0 0 0 0 0 0 0
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>
#define MOD 1000000007
#define N 100000

int main() {
	int num,i,j=0;
	long A[N];
	long count=1;
	int hat[3]={0,0,0};
	int hatnum=0;
	scanf("%d",&num);
	for(i=0; i<num; i++) {
    	scanf("%ld", &A[i]);
    }
	for(i=0; i<num; i++) {
		if(A[i]==hat[0]) {
			hatnum++;
			j=0;
		}
		if(A[i]==hat[1]) {
			hatnum++;
			j=1;
		}
		if(A[i]==hat[2]) {
			hatnum++;
			j=2;
		}
		switch(hatnum) {
			case 0:
				printf("0");
				return 0;
				break;
			case 1:
				break;
			case 2:
				count*=2;
				break;
			case 3:
				count*=3;
				break;
			default :
				printf("0");
				return 0;
				break;
		}
		hat[j]++;
		hatnum=0;
		if(count>MOD) {
			count %= MOD;
		}
	}
	printf("%ld",count);
	return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%d"
.LC1:
	.string	"%ld"
	.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
	leaq	-798720(%rsp), %r11
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	subq	$1344, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	$0, -800048(%rbp)
	movq	$1, -800040(%rbp)
	movl	$0, -800028(%rbp)
	movl	$0, -800024(%rbp)
	movl	$0, -800020(%rbp)
	movl	$0, -800044(%rbp)
	leaq	-800056(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -800052(%rbp)
	jmp	.L2
.L3:
	leaq	-800016(%rbp), %rdx
	movl	-800052(%rbp), %eax
	cltq
	salq	$3, %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -800052(%rbp)
.L2:
	movl	-800056(%rbp), %eax
	cmpl	%eax, -800052(%rbp)
	jl	.L3
	movl	$0, -800052(%rbp)
	jmp	.L4
.L16:
	movl	-800052(%rbp), %eax
	cltq
	movq	-800016(%rbp,%rax,8), %rdx
	movl	-800028(%rbp), %eax
	cltq
	cmpq	%rax, %rdx
	jne	.L5
	addl	$1, -800044(%rbp)
	movl	$0, -800048(%rbp)
.L5:
	movl	-800052(%rbp), %eax
	cltq
	movq	-800016(%rbp,%rax,8), %rdx
	movl	-800024(%rbp), %eax
	cltq
	cmpq	%rax, %rdx
	jne	.L6
	addl	$1, -800044(%rbp)
	movl	$1, -800048(%rbp)
.L6:
	movl	-800052(%rbp), %eax
	cltq
	movq	-800016(%rbp,%rax,8), %rdx
	movl	-800020(%rbp), %eax
	cltq
	cmpq	%rax, %rdx
	jne	.L7
	addl	$1, -800044(%rbp)
	movl	$2, -800048(%rbp)
.L7:
	cmpl	$3, -800044(%rbp)
	je	.L8
	cmpl	$3, -800044(%rbp)
	jg	.L9
	cmpl	$2, -800044(%rbp)
	je	.L10
	cmpl	$2, -800044(%rbp)
	jg	.L9
	cmpl	$0, -800044(%rbp)
	je	.L11
	cmpl	$1, -800044(%rbp)
	je	.L19
	jmp	.L9
.L11:
	movl	$48, %edi
	call	putchar@PLT
	movl	$0, %eax
	jmp	.L17
.L10:
	salq	-800040(%rbp)
	jmp	.L14
.L8:
	movq	-800040(%rbp), %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	movq	%rax, -800040(%rbp)
	jmp	.L14
.L9:
	movl	$48, %edi
	call	putchar@PLT
	movl	$0, %eax
	jmp	.L17
.L19:
	nop
.L14:
	movl	-800048(%rbp), %eax
	cltq
	movl	-800028(%rbp,%rax,4), %eax
	leal	1(%rax), %edx
	movl	-800048(%rbp), %eax
	cltq
	movl	%edx, -800028(%rbp,%rax,4)
	movl	$0, -800044(%rbp)
	cmpq	$1000000007, -800040(%rbp)
	jle	.L15
	movq	-800040(%rbp), %rcx
	movabsq	$-8543223828751151131, %rdx
	movq	%rcx, %rax
	imulq	%rdx
	leaq	(%rdx,%rcx), %rax
	sarq	$29, %rax
	movq	%rcx, %rdx
	sarq	$63, %rdx
	subq	%rdx, %rax
	imulq	$1000000007, %rax, %rdx
	movq	%rcx, %rax
	subq	%rdx, %rax
	movq	%rax, -800040(%rbp)
.L15:
	addl	$1, -800052(%rbp)
.L4:
	movl	-800056(%rbp), %eax
	cmpl	%eax, -800052(%rbp)
	jl	.L16
	movq	-800040(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
.L17:
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L18
	call	__stack_chk_fail@PLT
.L18:
	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	"%d"
.LC1:
	.string	"%ld"
	.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
	leaq	-798720(%rsp), %r11
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	subq	$1344, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movl	$0, -800048(%rbp)
	movq	$1, -800040(%rbp)
	movl	$0, -800028(%rbp)
	movl	$0, -800024(%rbp)
	movl	$0, -800020(%rbp)
	movl	$0, -800044(%rbp)
	leaq	-800056(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -800052(%rbp)
	jmp	.L2
.L3:
	leaq	-800016(%rbp), %rdx
	movl	-800052(%rbp), %eax
	cltq
	salq	$3, %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -800052(%rbp)
.L2:
	movl	-800056(%rbp), %eax
	cmpl	%eax, -800052(%rbp)
	jl	.L3
	movl	$0, -800052(%rbp)
	jmp	.L4
.L16:
	movl	-800052(%rbp), %eax
	cltq
	movq	-800016(%rbp,%rax,8), %rdx
	movl	-800028(%rbp), %eax
	cltq
	cmpq	%rax, %rdx
	jne	.L5
	addl	$1, -800044(%rbp)
	movl	$0, -800048(%rbp)
.L5:
	movl	-800052(%rbp), %eax
	cltq
	movq	-800016(%rbp,%rax,8), %rdx
	movl	-800024(%rbp), %eax
	cltq
	cmpq	%rax, %rdx
	jne	.L6
	addl	$1, -800044(%rbp)
	movl	$1, -800048(%rbp)
.L6:
	movl	-800052(%rbp), %eax
	cltq
	movq	-800016(%rbp,%rax,8), %rdx
	movl	-800020(%rbp), %eax
	cltq
	cmpq	%rax, %rdx
	jne	.L7
	addl	$1, -800044(%rbp)
	movl	$2, -800048(%rbp)
.L7:
	cmpl	$3, -800044(%rbp)
	je	.L8
	cmpl	$3, -800044(%rbp)
	jg	.L9
	cmpl	$2, -800044(%rbp)
	je	.L10
	cmpl	$2, -800044(%rbp)
	jg	.L9
	cmpl	$0, -800044(%rbp)
	je	.L11
	cmpl	$1, -800044(%rbp)
	je	.L19
	jmp	.L9
.L11:
	movl	$48, %edi
	call	putchar@PLT
	movl	$0, %eax
	jmp	.L17
.L10:
	salq	-800040(%rbp)
	jmp	.L14
.L8:
	movq	-800040(%rbp), %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	movq	%rax, -800040(%rbp)
	jmp	.L14
.L9:
	movl	$48, %edi
	call	putchar@PLT
	movl	$0, %eax
	jmp	.L17
.L19:
	nop
.L14:
	movl	-800048(%rbp), %eax
	cltq
	movl	-800028(%rbp,%rax,4), %eax
	leal	1(%rax), %edx
	movl	-800048(%rbp), %eax
	cltq
	movl	%edx, -800028(%rbp,%rax,4)
	movl	$0, -800044(%rbp)
	cmpq	$1000000007, -800040(%rbp)
	jle	.L15
	movq	-800040(%rbp), %rcx
	movabsq	$-8543223828751151131, %rdx
	movq	%rcx, %rax
	imulq	%rdx
	leaq	(%rdx,%rcx), %rax
	sarq	$29, %rax
	movq	%rcx, %rdx
	sarq	$63, %rdx
	subq	%rdx, %rax
	imulq	$1000000007, %rax, %rdx
	movq	%rcx, %rax
	subq	%rdx, %rax
	movq	%rax, -800040(%rbp)
.L15:
	addl	$1, -800052(%rbp)
.L4:
	movl	-800056(%rbp), %eax
	cmpl	%eax, -800052(%rbp)
	jl	.L16
	movq	-800040(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
	movl	$0, %eax
.L17:
	movq	-8(%rbp), %rdx
	subq	%fs:40, %rdx
	je	.L18
	call	__stack_chk_fail@PLT
.L18:
	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:
