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>

#define scanl(x) scanf("%ld", &x)
#define scans(x) scanf("%s", x)

#define INF 100000000000
#define M 1000000007

#define min(a,b) (((a)<(b))?(a):(b))
#define max(a,b) (((a)>(b))?(a):(b))

int main() {
	long N;
	long T[100001];
	long A[100001];
	int i;
	long m;
	long x[100001];
	long ans = 1;
	
	scanl(N);
	for(i=0;i<N;i++) {
		scanl(T[i]);
	}
	for(i=0;i<N;i++) {
		scanl(A[i]);
	}
	
	m = T[0];
	x[0] = T[0];
	for(i=1;i<N;i++) {
		if(m != T[i]) {
			x[i] = T[i];
			m = T[i];
			if(T[i] > A[i]) ans = 0;
		} else {
			x[i] = INF;
		}
	}
	m = A[N-1];
	x[N-1] = A[N-1];
	for(i=N-2;i>=0;i--) {
		if(m != A[i]) {
			x[i] = min(x[i], A[i]);
			m = A[i];
			if(A[i] > T[i]) ans = 0;
		}
	}
	
	for(i=0;i<N;i++) {
		if(x[i] == INF) {
			ans *= min(T[i], A[i]);
			ans %= M;
		}
	}
	
	if(T[N-1] != A[0]) ans = 0;
	printf("%ld\n", ans);
	
	return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%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
	leaq	-2396160(%rsp), %r11
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	subq	$3920, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movq	$1, -2400056(%rbp)
	leaq	-2400072(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -2400076(%rbp)
	jmp	.L2
.L3:
	leaq	-2400048(%rbp), %rdx
	movl	-2400076(%rbp), %eax
	cltq
	salq	$3, %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -2400076(%rbp)
.L2:
	movl	-2400076(%rbp), %eax
	movslq	%eax, %rdx
	movq	-2400072(%rbp), %rax
	cmpq	%rax, %rdx
	jl	.L3
	movl	$0, -2400076(%rbp)
	jmp	.L4
.L5:
	leaq	-1600032(%rbp), %rdx
	movl	-2400076(%rbp), %eax
	cltq
	salq	$3, %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -2400076(%rbp)
.L4:
	movl	-2400076(%rbp), %eax
	movslq	%eax, %rdx
	movq	-2400072(%rbp), %rax
	cmpq	%rax, %rdx
	jl	.L5
	movq	-2400048(%rbp), %rax
	movq	%rax, -2400064(%rbp)
	movq	-2400048(%rbp), %rax
	movq	%rax, -800016(%rbp)
	movl	$1, -2400076(%rbp)
	jmp	.L6
.L9:
	movl	-2400076(%rbp), %eax
	cltq
	movq	-2400048(%rbp,%rax,8), %rax
	cmpq	%rax, -2400064(%rbp)
	je	.L7
	movl	-2400076(%rbp), %eax
	cltq
	movq	-2400048(%rbp,%rax,8), %rdx
	movl	-2400076(%rbp), %eax
	cltq
	movq	%rdx, -800016(%rbp,%rax,8)
	movl	-2400076(%rbp), %eax
	cltq
	movq	-2400048(%rbp,%rax,8), %rax
	movq	%rax, -2400064(%rbp)
	movl	-2400076(%rbp), %eax
	cltq
	movq	-2400048(%rbp,%rax,8), %rdx
	movl	-2400076(%rbp), %eax
	cltq
	movq	-1600032(%rbp,%rax,8), %rax
	cmpq	%rax, %rdx
	jle	.L8
	movq	$0, -2400056(%rbp)
	jmp	.L8
.L7:
	movl	-2400076(%rbp), %eax
	cltq
	movabsq	$100000000000, %rsi
	movq	%rsi, -800016(%rbp,%rax,8)
.L8:
	addl	$1, -2400076(%rbp)
.L6:
	movl	-2400076(%rbp), %eax
	movslq	%eax, %rdx
	movq	-2400072(%rbp), %rax
	cmpq	%rax, %rdx
	jl	.L9
	movq	-2400072(%rbp), %rax
	subq	$1, %rax
	movq	-1600032(%rbp,%rax,8), %rax
	movq	%rax, -2400064(%rbp)
	movq	-2400072(%rbp), %rax
	subq	$1, %rax
	movq	-2400072(%rbp), %rdx
	subq	$1, %rdx
	movq	-1600032(%rbp,%rax,8), %rax
	movq	%rax, -800016(%rbp,%rdx,8)
	movq	-2400072(%rbp), %rax
	subl	$2, %eax
	movl	%eax, -2400076(%rbp)
	jmp	.L10
.L12:
	movl	-2400076(%rbp), %eax
	cltq
	movq	-1600032(%rbp,%rax,8), %rax
	cmpq	%rax, -2400064(%rbp)
	je	.L11
	movl	-2400076(%rbp), %eax
	cltq
	movq	-1600032(%rbp,%rax,8), %rdx
	movl	-2400076(%rbp), %eax
	cltq
	movq	-800016(%rbp,%rax,8), %rax
	cmpq	%rax, %rdx
	cmovg	%rax, %rdx
	movl	-2400076(%rbp), %eax
	cltq
	movq	%rdx, -800016(%rbp,%rax,8)
	movl	-2400076(%rbp), %eax
	cltq
	movq	-1600032(%rbp,%rax,8), %rax
	movq	%rax, -2400064(%rbp)
	movl	-2400076(%rbp), %eax
	cltq
	movq	-1600032(%rbp,%rax,8), %rdx
	movl	-2400076(%rbp), %eax
	cltq
	movq	-2400048(%rbp,%rax,8), %rax
	cmpq	%rax, %rdx
	jle	.L11
	movq	$0, -2400056(%rbp)
.L11:
	subl	$1, -2400076(%rbp)
.L10:
	cmpl	$0, -2400076(%rbp)
	jns	.L12
	movl	$0, -2400076(%rbp)
	jmp	.L13
.L15:
	movl	-2400076(%rbp), %eax
	cltq
	movq	-800016(%rbp,%rax,8), %rax
	movabsq	$100000000000, %rdx
	cmpq	%rdx, %rax
	jne	.L14
	movl	-2400076(%rbp), %eax
	cltq
	movq	-1600032(%rbp,%rax,8), %rdx
	movl	-2400076(%rbp), %eax
	cltq
	movq	-2400048(%rbp,%rax,8), %rax
	cmpq	%rax, %rdx
	cmovle	%rdx, %rax
	movq	-2400056(%rbp), %rdx
	imulq	%rdx, %rax
	movq	%rax, -2400056(%rbp)
	movq	-2400056(%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, -2400056(%rbp)
.L14:
	addl	$1, -2400076(%rbp)
.L13:
	movl	-2400076(%rbp), %eax
	movslq	%eax, %rdx
	movq	-2400072(%rbp), %rax
	cmpq	%rax, %rdx
	jl	.L15
	movq	-2400072(%rbp), %rax
	subq	$1, %rax
	movq	-2400048(%rbp,%rax,8), %rdx
	movq	-1600032(%rbp), %rax
	cmpq	%rax, %rdx
	je	.L16
	movq	$0, -2400056(%rbp)
.L16:
	movq	-2400056(%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	.L18
	call	__stack_chk_fail@PLT
.L18:
	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"
.LC1:
	.string	"%ld\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB51:
	.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	-2396160(%rsp), %r11
	.cfi_def_cfa 11, 2396208
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	.cfi_def_cfa_register 7
	subq	$3904, %rsp
	.cfi_def_cfa_offset 2400112
	leaq	.LC0(%rip), %r14
	movq	%r14, %rdi
	movq	%fs:40, %rax
	movq	%rax, 2400056(%rsp)
	xorl	%eax, %eax
	leaq	8(%rsp), %rsi
	call	__isoc99_scanf@PLT
	movq	8(%rsp), %rcx
	testq	%rcx, %rcx
	jle	.L2
	leaq	16(%rsp), %rbp
	xorl	%ebx, %ebx
	movq	%rbp, %r12
	.p2align 4,,10
	.p2align 3
.L3:
	movq	%r12, %rsi
	movq	%r14, %rdi
	xorl	%eax, %eax
	addq	$1, %rbx
	call	__isoc99_scanf@PLT
	movq	8(%rsp), %rcx
	addq	$8, %r12
	cmpq	%rbx, %rcx
	jg	.L3
	testq	%rcx, %rcx
	jle	.L2
	leaq	800032(%rsp), %rbx
	xorl	%r12d, %r12d
	movq	%rbx, %r13
	.p2align 4,,10
	.p2align 3
.L4:
	movq	%r13, %rsi
	movq	%r14, %rdi
	xorl	%eax, %eax
	addq	$1, %r12
	call	__isoc99_scanf@PLT
	movq	8(%rsp), %rcx
	addq	$8, %r13
	cmpq	%r12, %rcx
	jg	.L4
	movq	16(%rsp), %rdi
	leaq	-1(%rcx), %r9
	leal	-2(%rcx), %eax
	movq	800032(%rsp,%r9,8), %r11
	movq	%rdi, 1600048(%rsp)
	cmpq	$1, %rcx
	jle	.L5
	leaq	0(,%rcx,8), %r12
	movl	$8, %esi
	movl	$1, %edx
	movabsq	$100000000000, %r14
	leaq	1600048(%rsp), %r8
	xorl	%r13d, %r13d
	jmp	.L8
	.p2align 4,,10
	.p2align 3
.L33:
	cmpq	(%rbx,%rsi), %rdi
	movq	%rdi, (%r8,%rsi)
	cmovg	%r13, %rdx
	addq	$8, %rsi
	cmpq	%rsi, %r12
	je	.L32
.L8:
	movq	%rdi, %r10
	movq	0(%rbp,%rsi), %rdi
	cmpq	%rdi, %r10
	jne	.L33
	movq	%r14, (%r8,%rsi)
	addq	$8, %rsi
	cmpq	%rsi, %r12
	jne	.L8
.L32:
	movq	%r11, 1600048(%rsp,%r9,8)
	testl	%eax, %eax
	js	.L18
.L17:
	cltq
	leaq	16(%rsp), %rbp
	xorl	%r10d, %r10d
	.p2align 4,,10
	.p2align 3
.L12:
	movq	(%rbx,%rax,8), %rsi
	cmpq	%r11, %rsi
	je	.L11
	leaq	1600048(%rsp), %r8
	movq	%rsi, %r11
	movq	(%r8,%rax,8), %rdi
	cmpq	%rsi, %rdi
	cmovg	%rsi, %rdi
	cmpq	0(%rbp,%rax,8), %rsi
	cmovg	%r10, %rdx
	movq	%rdi, (%r8,%rax,8)
.L11:
	subq	$1, %rax
	testl	%eax, %eax
	jns	.L12
.L10:
	testq	%rcx, %rcx
	jle	.L13
	leaq	1600048(%rsp), %r8
.L18:
	xorl	%esi, %esi
	movabsq	$100000000000, %r10
	leaq	800032(%rsp), %rbx
	movabsq	$-8543223828751151131, %r11
	.p2align 4,,10
	.p2align 3
.L15:
	cmpq	%r10, (%r8,%rsi,8)
	jne	.L14
	movq	(%rbx,%rsi,8), %rax
	movq	16(%rsp,%rsi,8), %rdi
	cmpq	%rax, %rdi
	cmovg	%rax, %rdi
	imulq	%rdx, %rdi
	movq	%rdi, %rax
	imulq	%r11
	movq	%rdi, %rax
	sarq	$63, %rax
	addq	%rdi, %rdx
	sarq	$29, %rdx
	subq	%rax, %rdx
	imulq	$1000000007, %rdx, %rax
	movq	%rdi, %rdx
	subq	%rax, %rdx
.L14:
	addq	$1, %rsi
	cmpq	%rcx, %rsi
	jl	.L15
.L13:
	movq	800032(%rsp), %rax
	cmpq	%rax, 16(%rsp,%r9,8)
	movl	$0, %eax
	leaq	.LC1(%rip), %rsi
	cmovne	%rax, %rdx
	movl	$1, %edi
	call	__printf_chk@PLT
	movq	2400056(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L34
	addq	$2400064, %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
.L2:
	.cfi_restore_state
	movq	16(%rsp), %rax
	leaq	-1(%rcx), %r9
	movq	800032(%rsp,%r9,8), %r11
	movq	%rax, 1600048(%rsp)
	leal	-2(%rcx), %eax
.L5:
	movq	%r11, 1600048(%rsp,%r9,8)
	movl	$1, %edx
	testl	%eax, %eax
	js	.L10
	leaq	800032(%rsp), %rbx
	jmp	.L17
.L34:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE51:
	.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"
.LC1:
	.string	"%ld\n"
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB51:
	.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	-2396160(%rsp), %r11
	.cfi_def_cfa 11, 2396208
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	.cfi_def_cfa_register 7
	subq	$3904, %rsp
	.cfi_def_cfa_offset 2400112
	leaq	.LC0(%rip), %r14
	movq	%r14, %rdi
	movq	%fs:40, %rax
	movq	%rax, 2400056(%rsp)
	xorl	%eax, %eax
	leaq	8(%rsp), %rsi
	call	__isoc99_scanf@PLT
	movq	8(%rsp), %rcx
	testq	%rcx, %rcx
	jle	.L2
	leaq	16(%rsp), %rbp
	xorl	%ebx, %ebx
	movq	%rbp, %r12
	.p2align 4,,10
	.p2align 3
.L3:
	movq	%r12, %rsi
	movq	%r14, %rdi
	xorl	%eax, %eax
	addq	$1, %rbx
	call	__isoc99_scanf@PLT
	movq	8(%rsp), %rcx
	addq	$8, %r12
	cmpq	%rbx, %rcx
	jg	.L3
	testq	%rcx, %rcx
	jle	.L2
	leaq	800032(%rsp), %rbx
	xorl	%r12d, %r12d
	movq	%rbx, %r13
	.p2align 4,,10
	.p2align 3
.L4:
	movq	%r13, %rsi
	movq	%r14, %rdi
	xorl	%eax, %eax
	addq	$1, %r12
	call	__isoc99_scanf@PLT
	movq	8(%rsp), %rcx
	addq	$8, %r13
	cmpq	%r12, %rcx
	jg	.L4
	movq	16(%rsp), %rdi
	leaq	-1(%rcx), %r9
	leal	-2(%rcx), %eax
	movq	800032(%rsp,%r9,8), %r11
	movq	%rdi, 1600048(%rsp)
	cmpq	$1, %rcx
	jle	.L5
	leaq	0(,%rcx,8), %r12
	movl	$8, %esi
	movl	$1, %edx
	movabsq	$100000000000, %r14
	leaq	1600048(%rsp), %r8
	xorl	%r13d, %r13d
	jmp	.L8
	.p2align 4,,10
	.p2align 3
.L33:
	cmpq	(%rbx,%rsi), %rdi
	movq	%rdi, (%r8,%rsi)
	cmovg	%r13, %rdx
	addq	$8, %rsi
	cmpq	%rsi, %r12
	je	.L32
.L8:
	movq	%rdi, %r10
	movq	0(%rbp,%rsi), %rdi
	cmpq	%rdi, %r10
	jne	.L33
	movq	%r14, (%r8,%rsi)
	addq	$8, %rsi
	cmpq	%rsi, %r12
	jne	.L8
.L32:
	movq	%r11, 1600048(%rsp,%r9,8)
	testl	%eax, %eax
	js	.L18
.L17:
	cltq
	leaq	16(%rsp), %rbp
	xorl	%r10d, %r10d
	.p2align 4,,10
	.p2align 3
.L12:
	movq	(%rbx,%rax,8), %rsi
	cmpq	%r11, %rsi
	je	.L11
	leaq	1600048(%rsp), %r8
	movq	%rsi, %r11
	movq	(%r8,%rax,8), %rdi
	cmpq	%rsi, %rdi
	cmovg	%rsi, %rdi
	cmpq	0(%rbp,%rax,8), %rsi
	cmovg	%r10, %rdx
	movq	%rdi, (%r8,%rax,8)
.L11:
	subq	$1, %rax
	testl	%eax, %eax
	jns	.L12
.L10:
	testq	%rcx, %rcx
	jle	.L13
	leaq	1600048(%rsp), %r8
.L18:
	xorl	%esi, %esi
	movabsq	$100000000000, %r10
	leaq	800032(%rsp), %rbx
	movabsq	$-8543223828751151131, %r11
	.p2align 4,,10
	.p2align 3
.L15:
	cmpq	%r10, (%r8,%rsi,8)
	jne	.L14
	movq	(%rbx,%rsi,8), %rax
	movq	16(%rsp,%rsi,8), %rdi
	cmpq	%rax, %rdi
	cmovg	%rax, %rdi
	imulq	%rdx, %rdi
	movq	%rdi, %rax
	imulq	%r11
	movq	%rdi, %rax
	sarq	$63, %rax
	addq	%rdi, %rdx
	sarq	$29, %rdx
	subq	%rax, %rdx
	imulq	$1000000007, %rdx, %rax
	movq	%rdi, %rdx
	subq	%rax, %rdx
.L14:
	addq	$1, %rsi
	cmpq	%rcx, %rsi
	jl	.L15
.L13:
	movq	800032(%rsp), %rax
	cmpq	%rax, 16(%rsp,%r9,8)
	movl	$0, %eax
	leaq	.LC1(%rip), %rsi
	cmovne	%rax, %rdx
	movl	$1, %edi
	call	__printf_chk@PLT
	movq	2400056(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L34
	addq	$2400064, %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
.L2:
	.cfi_restore_state
	movq	16(%rsp), %rax
	leaq	-1(%rcx), %r9
	movq	800032(%rsp,%r9,8), %r11
	movq	%rax, 1600048(%rsp)
	leal	-2(%rcx), %eax
.L5:
	movq	%r11, 1600048(%rsp,%r9,8)
	movl	$1, %edx
	testl	%eax, %eax
	js	.L10
	leaq	800032(%rsp), %rbx
	jmp	.L17
.L34:
	call	__stack_chk_fail@PLT
	.cfi_endproc
.LFE51:
	.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>

#define scanl(x) scanf("%ld", &x)
#define scans(x) scanf("%s", x)

#define INF 100000000000
#define M 1000000007

#define min(a,b) (((a)<(b))?(a):(b))
#define max(a,b) (((a)>(b))?(a):(b))

int main() {
	long N;
	long T[100001];
	long A[100001];
	int i;
	long m;
	long x[100001];
	long ans = 1;
	
	scanl(N);
	for(i=0;i<N;i++) {
		scanl(T[i]);
	}
	for(i=0;i<N;i++) {
		scanl(A[i]);
	}
	
	m = T[0];
	x[0] = T[0];
	for(i=1;i<N;i++) {
		if(m != T[i]) {
			x[i] = T[i];
			m = T[i];
			if(T[i] > A[i]) ans = 0;
		} else {
			x[i] = INF;
		}
	}
	m = A[N-1];
	x[N-1] = A[N-1];
	for(i=N-2;i>=0;i--) {
		if(m != A[i]) {
			x[i] = min(x[i], A[i]);
			m = A[i];
			if(A[i] > T[i]) ans = 0;
		}
	}
	
	for(i=0;i<N;i++) {
		if(x[i] == INF) {
			ans *= min(T[i], A[i]);
			ans %= M;
		}
	}
	
	if(T[N-1] != A[0]) ans = 0;
	printf("%ld\n", ans);
	
	return 0;
}
5
2 3 3 3 3
3 3 2 2 2
 5
1 1 1 2 2
6 2 1 1 1
 5
1 1 1 4 2
6 2 1 1 1
 5
1 1 1 4 2
6 2 1 1 0
 5
1 1 1 4 2
6 0 1 1 0
 5
1 1 1 4 2
6 1 1 1 0
 5
1 1 1 4 2
6 2 1 2 0
 5
1 1 1 4 2
9 2 1 2 0
 5
1 1 1 1 2
9 2 1 2 0
 5
1 1 1 1 2
9 2 1 2 -1

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

#define scanl(x) scanf("%ld", &x)
#define scans(x) scanf("%s", x)

#define INF 100000000000
#define M 1000000007

#define min(a,b) (((a)<(b))?(a):(b))
#define max(a,b) (((a)>(b))?(a):(b))

int main() {
	long N;
	long T[100001];
	long A[100001];
	int i;
	long m;
	long x[100001];
	long ans = 1;
	
	scanl(N);
	for(i=0;i<N;i++) {
		scanl(T[i]);
	}
	for(i=0;i<N;i++) {
		scanl(A[i]);
	}
	
	m = T[0];
	x[0] = T[0];
	for(i=1;i<N;i++) {
		if(m != T[i]) {
			x[i] = T[i];
			m = T[i];
			if(T[i] > A[i]) ans = 0;
		} else {
			x[i] = INF;
		}
	}
	m = A[N-1];
	x[N-1] = A[N-1];
	for(i=N-2;i>=0;i--) {
		if(m != A[i]) {
			x[i] = min(x[i], A[i]);
			m = A[i];
			if(A[i] > T[i]) ans = 0;
		}
	}
	
	for(i=0;i<N;i++) {
		if(x[i] == INF) {
			ans *= min(T[i], A[i]);
			ans %= M;
		}
	}
	
	if(T[N-1] != A[0]) ans = 0;
	printf("%ld\n", ans);
	
	return 0;
}```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.section	.rodata
.LC0:
	.string	"%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
	leaq	-2396160(%rsp), %r11
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	subq	$3920, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movq	$1, -2400056(%rbp)
	leaq	-2400072(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -2400076(%rbp)
	jmp	.L2
.L3:
	leaq	-2400048(%rbp), %rdx
	movl	-2400076(%rbp), %eax
	cltq
	salq	$3, %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -2400076(%rbp)
.L2:
	movl	-2400076(%rbp), %eax
	movslq	%eax, %rdx
	movq	-2400072(%rbp), %rax
	cmpq	%rax, %rdx
	jl	.L3
	movl	$0, -2400076(%rbp)
	jmp	.L4
.L5:
	leaq	-1600032(%rbp), %rdx
	movl	-2400076(%rbp), %eax
	cltq
	salq	$3, %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -2400076(%rbp)
.L4:
	movl	-2400076(%rbp), %eax
	movslq	%eax, %rdx
	movq	-2400072(%rbp), %rax
	cmpq	%rax, %rdx
	jl	.L5
	movq	-2400048(%rbp), %rax
	movq	%rax, -2400064(%rbp)
	movq	-2400048(%rbp), %rax
	movq	%rax, -800016(%rbp)
	movl	$1, -2400076(%rbp)
	jmp	.L6
.L9:
	movl	-2400076(%rbp), %eax
	cltq
	movq	-2400048(%rbp,%rax,8), %rax
	cmpq	%rax, -2400064(%rbp)
	je	.L7
	movl	-2400076(%rbp), %eax
	cltq
	movq	-2400048(%rbp,%rax,8), %rdx
	movl	-2400076(%rbp), %eax
	cltq
	movq	%rdx, -800016(%rbp,%rax,8)
	movl	-2400076(%rbp), %eax
	cltq
	movq	-2400048(%rbp,%rax,8), %rax
	movq	%rax, -2400064(%rbp)
	movl	-2400076(%rbp), %eax
	cltq
	movq	-2400048(%rbp,%rax,8), %rdx
	movl	-2400076(%rbp), %eax
	cltq
	movq	-1600032(%rbp,%rax,8), %rax
	cmpq	%rax, %rdx
	jle	.L8
	movq	$0, -2400056(%rbp)
	jmp	.L8
.L7:
	movl	-2400076(%rbp), %eax
	cltq
	movabsq	$100000000000, %rsi
	movq	%rsi, -800016(%rbp,%rax,8)
.L8:
	addl	$1, -2400076(%rbp)
.L6:
	movl	-2400076(%rbp), %eax
	movslq	%eax, %rdx
	movq	-2400072(%rbp), %rax
	cmpq	%rax, %rdx
	jl	.L9
	movq	-2400072(%rbp), %rax
	subq	$1, %rax
	movq	-1600032(%rbp,%rax,8), %rax
	movq	%rax, -2400064(%rbp)
	movq	-2400072(%rbp), %rax
	subq	$1, %rax
	movq	-2400072(%rbp), %rdx
	subq	$1, %rdx
	movq	-1600032(%rbp,%rax,8), %rax
	movq	%rax, -800016(%rbp,%rdx,8)
	movq	-2400072(%rbp), %rax
	subl	$2, %eax
	movl	%eax, -2400076(%rbp)
	jmp	.L10
.L12:
	movl	-2400076(%rbp), %eax
	cltq
	movq	-1600032(%rbp,%rax,8), %rax
	cmpq	%rax, -2400064(%rbp)
	je	.L11
	movl	-2400076(%rbp), %eax
	cltq
	movq	-1600032(%rbp,%rax,8), %rdx
	movl	-2400076(%rbp), %eax
	cltq
	movq	-800016(%rbp,%rax,8), %rax
	cmpq	%rax, %rdx
	cmovg	%rax, %rdx
	movl	-2400076(%rbp), %eax
	cltq
	movq	%rdx, -800016(%rbp,%rax,8)
	movl	-2400076(%rbp), %eax
	cltq
	movq	-1600032(%rbp,%rax,8), %rax
	movq	%rax, -2400064(%rbp)
	movl	-2400076(%rbp), %eax
	cltq
	movq	-1600032(%rbp,%rax,8), %rdx
	movl	-2400076(%rbp), %eax
	cltq
	movq	-2400048(%rbp,%rax,8), %rax
	cmpq	%rax, %rdx
	jle	.L11
	movq	$0, -2400056(%rbp)
.L11:
	subl	$1, -2400076(%rbp)
.L10:
	cmpl	$0, -2400076(%rbp)
	jns	.L12
	movl	$0, -2400076(%rbp)
	jmp	.L13
.L15:
	movl	-2400076(%rbp), %eax
	cltq
	movq	-800016(%rbp,%rax,8), %rax
	movabsq	$100000000000, %rdx
	cmpq	%rdx, %rax
	jne	.L14
	movl	-2400076(%rbp), %eax
	cltq
	movq	-1600032(%rbp,%rax,8), %rdx
	movl	-2400076(%rbp), %eax
	cltq
	movq	-2400048(%rbp,%rax,8), %rax
	cmpq	%rax, %rdx
	cmovle	%rdx, %rax
	movq	-2400056(%rbp), %rdx
	imulq	%rdx, %rax
	movq	%rax, -2400056(%rbp)
	movq	-2400056(%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, -2400056(%rbp)
.L14:
	addl	$1, -2400076(%rbp)
.L13:
	movl	-2400076(%rbp), %eax
	movslq	%eax, %rdx
	movq	-2400072(%rbp), %rax
	cmpq	%rax, %rdx
	jl	.L15
	movq	-2400072(%rbp), %rax
	subq	$1, %rax
	movq	-2400048(%rbp,%rax,8), %rdx
	movq	-1600032(%rbp), %rax
	cmpq	%rax, %rdx
	je	.L16
	movq	$0, -2400056(%rbp)
.L16:
	movq	-2400056(%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	.L18
	call	__stack_chk_fail@PLT
.L18:
	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"
.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
	leaq	-2396160(%rsp), %r11
.LPSRL0:
	subq	$4096, %rsp
	orq	$0, (%rsp)
	cmpq	%r11, %rsp
	jne	.LPSRL0
	subq	$3920, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	movq	$1, -2400056(%rbp)
	leaq	-2400072(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	$0, -2400076(%rbp)
	jmp	.L2
.L3:
	leaq	-2400048(%rbp), %rdx
	movl	-2400076(%rbp), %eax
	cltq
	salq	$3, %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -2400076(%rbp)
.L2:
	movl	-2400076(%rbp), %eax
	movslq	%eax, %rdx
	movq	-2400072(%rbp), %rax
	cmpq	%rax, %rdx
	jl	.L3
	movl	$0, -2400076(%rbp)
	jmp	.L4
.L5:
	leaq	-1600032(%rbp), %rdx
	movl	-2400076(%rbp), %eax
	cltq
	salq	$3, %rax
	addq	%rdx, %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	addl	$1, -2400076(%rbp)
.L4:
	movl	-2400076(%rbp), %eax
	movslq	%eax, %rdx
	movq	-2400072(%rbp), %rax
	cmpq	%rax, %rdx
	jl	.L5
	movq	-2400048(%rbp), %rax
	movq	%rax, -2400064(%rbp)
	movq	-2400048(%rbp), %rax
	movq	%rax, -800016(%rbp)
	movl	$1, -2400076(%rbp)
	jmp	.L6
.L9:
	movl	-2400076(%rbp), %eax
	cltq
	movq	-2400048(%rbp,%rax,8), %rax
	cmpq	%rax, -2400064(%rbp)
	je	.L7
	movl	-2400076(%rbp), %eax
	cltq
	movq	-2400048(%rbp,%rax,8), %rdx
	movl	-2400076(%rbp), %eax
	cltq
	movq	%rdx, -800016(%rbp,%rax,8)
	movl	-2400076(%rbp), %eax
	cltq
	movq	-2400048(%rbp,%rax,8), %rax
	movq	%rax, -2400064(%rbp)
	movl	-2400076(%rbp), %eax
	cltq
	movq	-2400048(%rbp,%rax,8), %rdx
	movl	-2400076(%rbp), %eax
	cltq
	movq	-1600032(%rbp,%rax,8), %rax
	cmpq	%rax, %rdx
	jle	.L8
	movq	$0, -2400056(%rbp)
	jmp	.L8
.L7:
	movl	-2400076(%rbp), %eax
	cltq
	movabsq	$100000000000, %rsi
	movq	%rsi, -800016(%rbp,%rax,8)
.L8:
	addl	$1, -2400076(%rbp)
.L6:
	movl	-2400076(%rbp), %eax
	movslq	%eax, %rdx
	movq	-2400072(%rbp), %rax
	cmpq	%rax, %rdx
	jl	.L9
	movq	-2400072(%rbp), %rax
	subq	$1, %rax
	movq	-1600032(%rbp,%rax,8), %rax
	movq	%rax, -2400064(%rbp)
	movq	-2400072(%rbp), %rax
	subq	$1, %rax
	movq	-2400072(%rbp), %rdx
	subq	$1, %rdx
	movq	-1600032(%rbp,%rax,8), %rax
	movq	%rax, -800016(%rbp,%rdx,8)
	movq	-2400072(%rbp), %rax
	subl	$2, %eax
	movl	%eax, -2400076(%rbp)
	jmp	.L10
.L12:
	movl	-2400076(%rbp), %eax
	cltq
	movq	-1600032(%rbp,%rax,8), %rax
	cmpq	%rax, -2400064(%rbp)
	je	.L11
	movl	-2400076(%rbp), %eax
	cltq
	movq	-1600032(%rbp,%rax,8), %rdx
	movl	-2400076(%rbp), %eax
	cltq
	movq	-800016(%rbp,%rax,8), %rax
	cmpq	%rax, %rdx
	cmovg	%rax, %rdx
	movl	-2400076(%rbp), %eax
	cltq
	movq	%rdx, -800016(%rbp,%rax,8)
	movl	-2400076(%rbp), %eax
	cltq
	movq	-1600032(%rbp,%rax,8), %rax
	movq	%rax, -2400064(%rbp)
	movl	-2400076(%rbp), %eax
	cltq
	movq	-1600032(%rbp,%rax,8), %rdx
	movl	-2400076(%rbp), %eax
	cltq
	movq	-2400048(%rbp,%rax,8), %rax
	cmpq	%rax, %rdx
	jle	.L11
	movq	$0, -2400056(%rbp)
.L11:
	subl	$1, -2400076(%rbp)
.L10:
	cmpl	$0, -2400076(%rbp)
	jns	.L12
	movl	$0, -2400076(%rbp)
	jmp	.L13
.L15:
	movl	-2400076(%rbp), %eax
	cltq
	movq	-800016(%rbp,%rax,8), %rax
	movabsq	$100000000000, %rdx
	cmpq	%rdx, %rax
	jne	.L14
	movl	-2400076(%rbp), %eax
	cltq
	movq	-1600032(%rbp,%rax,8), %rdx
	movl	-2400076(%rbp), %eax
	cltq
	movq	-2400048(%rbp,%rax,8), %rax
	cmpq	%rax, %rdx
	cmovle	%rdx, %rax
	movq	-2400056(%rbp), %rdx
	imulq	%rdx, %rax
	movq	%rax, -2400056(%rbp)
	movq	-2400056(%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, -2400056(%rbp)
.L14:
	addl	$1, -2400076(%rbp)
.L13:
	movl	-2400076(%rbp), %eax
	movslq	%eax, %rdx
	movq	-2400072(%rbp), %rax
	cmpq	%rax, %rdx
	jl	.L15
	movq	-2400072(%rbp), %rax
	subq	$1, %rax
	movq	-2400048(%rbp,%rax,8), %rdx
	movq	-1600032(%rbp), %rax
	cmpq	%rax, %rdx
	je	.L16
	movq	$0, -2400056(%rbp)
.L16:
	movq	-2400056(%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	.L18
	call	__stack_chk_fail@PLT
.L18:
	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:
